public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter) { if (IsEnabled(logLevel)) { RavenLogEntry entry = new RavenLogEntry(); entry.Category = this.Category; entry.Level = logLevel; entry.Text = formatter(state, exception); entry.Exception = exception; entry.EventId = eventId; var httpContext = this.httpContextAccessor.HttpContext; if (httpContext != null) { entry.TraceIdentifier = httpContext.TraceIdentifier; entry.IdentityName = httpContext.User.Identity.Name; entry.RequestPath = httpContext.Request.Path; } entry.State = ToDictionary(state); if (Options.IncludeScopes) { ScopeProvider.ForEachScope((scope, _) => { if (entry.Scopes == null) { entry.Scopes = new List <Dictionary <string, object> >(); } entry.Scopes.Add(ToDictionary(scope)); }, null as object); } loggerProcessor.EnqueueLogEntry(entry); } }
public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter) { ScopeProvider.ForEachScope((scopeObject, state) => { Scopes.Add(scopeObject); }, 0); _logDelegate(Scopes); }
public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter) { LogText.Add(formatter(state, exception)); // Notice that other ILoggers maybe not call "ToString()" on the scope but enumerate it and this isn't covered by this implementation. // E.g. the SimpleConsoleFormatter calls "ToString()" like it's done here but the "JsonConsoleFormatter" enumerates a scope // if the Scope is of type IEnumerable<KeyValuePair<string, object>>. ScopeProvider.ForEachScope((scope, builder) => builder.Add(scope.ToString()), LogText); }
public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter) { LogText.Add(formatter(state, exception)); ScopeProvider.ForEachScope((scope, builder) => builder.Add(scope.ToString()), LogText); }