public TraceManagerConfig(TraceWriterConfig traceWriterConfig) : this(new LogManagerConfig()) { Contract.Requires <ArgumentNullException>(traceWriterConfig != null); _traceWriterConfigs.Add(traceWriterConfig); }
private void OnAddingTraceWriterConfig(TraceWriterConfig traceWriterConfig) { if (traceWriterConfig != null) { LogManagerConfig.Writers.UnionWith(new ILogWriterConfig[] { traceWriterConfig.LogWriterConfig }); } }
private void OnRemovingTraceWriterConfig(TraceWriterConfig traceWriterConfig) { // Don't remove the TraceWriterConfig, b/c we can't be sure that other formatters/encoders/etc don't support it. //if (traceWriterConfig != null) //{ // LogManagerConfig.Writers.Remove(traceWriterConfig.LogWriterConfig); //} }
/// <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); }
/// <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); }
/// <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); }