private void timerCallback(object state) { lock (_synObj) { if (_sb.Length != 0) { _control.Append(_sb.ToString()); _sb.Clear(); } } }
public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter) { if (IsEnabled(logLevel)) { if (formatter == null) { throw new ArgumentNullException("formatter"); } string text = formatter(state, exception); if (!string.IsNullOrEmpty(text)) { text = $"{DateTime.Now.ToLongTimeString()} {LogLevelInChinese[logLevel]}: {text}{Environment.NewLine}"; if (exception != null) { text = text + Environment.NewLine + Environment.NewLine + exception.ToString(); } _control.Append(text); } } }