public TraceWriterConfig(ILogWriterConfig logWriterConfig, SwitchSet switches = null) { Contract.Requires <ArgumentNullException>(logWriterConfig != null); _tracelogWriterConfig = logWriterConfig; _switches = switches ?? new SwitchSet(); }
/// <summary> /// Enables sending trace messages to all configured log writers. /// </summary> /// <param name="traceManager"></param> /// <param name="switches"></param> /// <param name="traceFormatter"></param> /// <returns></returns> public static void TraceToAllLogWriters(this TraceManagerConfig config, SwitchSet switches = null, EntryFormatter <TraceEntry> traceFormatter = null) { Contract.Requires <ArgumentNullException>(config != null); TraceTo(config, config.LogManagerConfig.Writers, switches, traceFormatter); }
public static TraceWriterConfig TraceTo(this TraceManagerConfig traceManagerConfig, Func <TextWriter> createTextWriterFunc, SwitchSet switchSet, EntryFormatter <TraceEntry> traceFormatter = null) { Contract.Requires <ArgumentNullException>(traceManagerConfig != null); Contract.Requires <ArgumentNullException>(createTextWriterFunc != null); Contract.Requires <ArgumentNullException>(switchSet != null); return(TraceTo(traceManagerConfig, new TextWriterLogWriterConfig(createTextWriterFunc), switchSet, traceFormatter)); }
/// <summary> /// Trace to the text logwriter configured by <paramref name="textLogWriterConfig" />. /// </summary> /// <param name="traceManagerConfig"></param> /// <param name="textLogWriterConfig"></param> /// <param name="switchSet"></param> /// <param name="traceFormatter"></param> /// <returns></returns> public static TraceWriterConfig TraceTo(this TraceManagerConfig traceManagerConfig, TextLogWriterConfig textLogWriterConfig, SwitchSet switchSet, EntryFormatter <TraceEntry> traceFormatter = null) { Contract.Requires <ArgumentNullException>(traceManagerConfig != null); Contract.Requires <ArgumentNullException>(textLogWriterConfig != null); Contract.Requires <ArgumentNullException>(switchSet != null); textLogWriterConfig.Format(traceFormatter); var traceWriterConfig = new TraceWriterConfig(textLogWriterConfig, switchSet); traceManagerConfig.Writers.Add(traceWriterConfig); return(traceWriterConfig); }
/// <summary> /// Enables sending trace messages to all specified <paramref name="logWriterConfigs" />. This method can be called /// multiple times /// to specify different switch settings for different logWriters. /// </summary> /// <param name="traceManagerConfig"></param> /// <param name="logWriterConfigs"></param> /// <param name="switches"></param> /// <param name="traceFormatter"></param> /// <returns></returns> public static void TraceTo(this TraceManagerConfig traceManagerConfig, IEnumerable <ILogWriterConfig> logWriterConfigs, SwitchSet switches = null, EntryFormatter <TraceEntry> traceFormatter = null) { Contract.Requires <ArgumentNullException>(traceManagerConfig != null); Contract.Requires <ArgumentNullException>(logWriterConfigs != null); if (switches == null) { switches = TraceManagerConfig.CreateDefaultSwitchSet(); } logWriterConfigs.FormatAll(traceFormatter); foreach (var logWriterConfig in logWriterConfigs) { traceManagerConfig.Writers.Add(new TraceWriterConfig(logWriterConfig, switches)); } }
public TraceWriterConfig(ILogWriter logWriter, SwitchSet switches = null) : this(new UseExistingLogWriterConfig(logWriter), switches) { Contract.Requires <ArgumentNullException>(logWriter != null); }
/// <summary> /// Creates a new <see cref="TraceWriterConfig" /> using all default values. /// If <see cref="LogWriterConfig" /> is not subsequently set, a <see cref="NoOpEntryWriter{TEntry}" /> will be /// used. /// </summary> public TraceWriterConfig() { _switches = new SwitchSet(); }
/// <summary> /// Trace to the logwriter configured by <paramref name="logWriterConfig" />. /// </summary> /// <param name="traceManagerConfig"></param> /// <param name="logWriterConfig"></param> /// <param name="switchSet"></param> /// <returns></returns> public static TraceWriterConfig TraceTo(this TraceManagerConfig traceManagerConfig, LogWriterConfig logWriterConfig, SwitchSet switchSet) { Contract.Requires <ArgumentNullException>(traceManagerConfig != null); Contract.Requires <ArgumentNullException>(logWriterConfig != null); Contract.Requires <ArgumentNullException>(switchSet != null); var traceWriterConfig = new TraceWriterConfig(logWriterConfig, switchSet); traceManagerConfig.Writers.Add(traceWriterConfig); return(traceWriterConfig); }
public static TraceWriterConfig TraceToList(this TraceManagerConfig traceManagerConfig, IList <TraceEntry> list, SwitchSet switchSet) { Contract.Requires <ArgumentNullException>(traceManagerConfig != null); Contract.Requires <ArgumentNullException>(list != null); Contract.Requires <ArgumentNullException>(switchSet != null); var listLogWriterConfig = new ListLogWriterConfig <TraceEntry>() { List = list }; return(TraceTo(traceManagerConfig, listLogWriterConfig, switchSet)); }
public static TraceWriterConfig TraceToDebugger(this TraceManagerConfig traceManagerConfig, SwitchSet switchSet, EntryFormatter <TraceEntry> traceFormatter = null) { Contract.Requires <ArgumentNullException>(traceManagerConfig != null); Contract.Requires <ArgumentNullException>(switchSet != null); DebuggerLogWriterConfig debuggerLogWriterConfig = traceManagerConfig.LogManagerConfig.UseDebugger(); return(TraceTo(traceManagerConfig, debuggerLogWriterConfig, switchSet, traceFormatter)); }
public static TraceWriterConfig TraceToConsole(this TraceManagerConfig traceManagerConfig, SwitchSet switchSet, EntryFormatter <TraceEntry> traceFormatter = null, bool colorize = true) { Contract.Requires <ArgumentNullException>(traceManagerConfig != null); Contract.Requires <ArgumentNullException>(switchSet != null); ConsoleLogWriterConfig consoleLogWriterConfig = traceManagerConfig.LogManagerConfig.UseConsole(colorize); return(TraceTo(traceManagerConfig, consoleLogWriterConfig, switchSet, traceFormatter)); }
/// <summary> /// Use an existing <paramref name="logWriter" /> along with the specified <paramref name="switchSet" />. /// </summary> /// <param name="config"></param> /// <param name="logWriter"></param> /// <param name="switchSet"></param> public static TraceWriterConfig UseLogWriter(this TraceManagerConfig config, ILogWriter logWriter, SwitchSet switchSet) { Contract.Requires <ArgumentNullException>(config != null); Contract.Requires <ArgumentNullException>(logWriter != null); Contract.Requires <ArgumentNullException>(switchSet != null); var traceWriterConfig = new TraceWriterConfig(logWriter, switchSet); config.Writers.Add(traceWriterConfig); return(traceWriterConfig); }