public Deferred(LogState state) { _state = state; _writer = state._deferWriter; _color = state._deferColor; _line = state._deferLine; _time = state._deferTime; }
public Log(TextWriter outWriter = null, TextWriter errorWriter = null, LogState state = null) { if (outWriter == null) { outWriter = Console.Out; } if (errorWriter == null) { errorWriter = outWriter == Console.Out ? Console.Error : outWriter; } _state = state ?? new LogState(); OutWriter = new LogWriter(_state, outWriter); ErrorWriter = new LogWriter(_state, errorWriter); EnableAnimation = outWriter == Console.Out && !Console.IsOutputRedirected; }
internal IDisposable BeginDeferred(TextWriter writer, string line, ConsoleColor?color, bool animate) { if (writer == TextWriter.Null) { return(writer); } Flush(writer); SetColor(writer, color); writer.Write(line); _deferLine = line; _deferTime = Time; _deferWriter = writer; _deferColor = color; _lastLine = null; if (animate) { if (_timer == null) { _timer = new Timer(_interval); _timer.Elapsed += (_, __) => { lock (_animated) if (_timer.Enabled) // Check race condition { lock (_animated._deferWriter) // Don't race with i.e. Stuff.Log _animated.Tick(); } // (or anything locking Console.Out) }; } _animated = this; _timer.Enabled = true; } return(new Deferred(this)); }
public Log(IErrorList errors, TextWriter outWriter = null, TextWriter errorWriter = null, LogState state = null) : this(outWriter, errorWriter, state) { Errors = errors ?? ErrorList.Null; }
internal LogWriter(LogState state, TextWriter w) { _state = state; Inner = (w as LogWriter)?.Inner ?? w; }