/// <inheritdoc /> public void Log(LogLevel logLevel, int eventId, object state, Exception exception, Func <object, Exception, string> formatter) { if (!IsEnabled(logLevel)) { return; } string message; var values = state as ILogValues; if (formatter != null) { message = formatter(state, exception); } else if (values != null) { message = LogFormatter.FormatLogValues(values); if (exception != null) { message += Environment.NewLine + exception; } } else { message = LogFormatter.Formatter(state, exception); } if (string.IsNullOrEmpty(message)) { return; } message = $"{ logLevel }: {message}"; DebugWriteLine(message, _name); }
/// <inheritdoc /> public void Log( LogLevel logLevel, int eventId, object state, Exception exception, Func <object, Exception, string> formatter) { if (!IsEnabled(logLevel)) { return; } string message; var values = state as ILogValues; if (formatter != null) { message = formatter(state, exception); } else if (values != null) { message = LogFormatter.FormatLogValues(values); if (exception != null) { message += Environment.NewLine + exception; } } else { message = LogFormatter.Formatter(state, exception); } if (string.IsNullOrEmpty(message)) { return; } message = _name + Environment.NewLine + message; // category '0' translates to 'None' in event log _eventLog.WriteEntry(message, GetEventLogEntryType(logLevel), eventId, category: 0); }