in src/Google.Cloud.Functions.Hosting/Logging/LoggerBase.cs [38:66]
protected LoggerBase(string category, IExternalScopeProvider? scopeProvider) =>
(Category, _isKestrelCategory, ScopeProvider) =
(category, category == KestrelCategory, scopeProvider ?? new LoggerExternalScopeProvider());
public IDisposable BeginScope<TState>(TState state) where TState : notnull =>
ScopeProvider.Push(state);
// Note: log level filtering is handled by other logging infrastructure, so we don't do any of it here.
public bool IsEnabled(LogLevel logLevel) => logLevel != LogLevel.None;
/// <summary>
/// Performs common filtering and formats the message, before delegating
/// to <see cref="LogImpl{TState}"/>.
/// </summary>
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
{
// Functions expect to go for a long time without any CPU. It's reasonable to suppress this warning.
if (_isKestrelCategory && eventId.Id == HeartbeatSlowEventId)
{
return;
}
string message = formatter(state, exception);
if (string.IsNullOrEmpty(message))
{
return;
}
LogImpl(logLevel, eventId, state, exception, message);
}