1using Microsoft.Extensions.Logging;
9internal static class Logger
11 private static ILogger? s_logger;
16 public static ILogger Instance
22 s_logger = InitializeDefaultLogger();
33 public static void Initialize(ILogger logger)
45 private static ILogger InitializeDefaultLogger()
47 var logLevel = Environment.GetEnvironmentVariable(
"FAUNA_DEBUG");
48 var minLogLevel = LogLevel.None;
50 if (!
string.IsNullOrEmpty(logLevel) &&
int.TryParse(logLevel, out var level))
52 if (level < (
int)LogLevel.Trace || level > (
int)LogLevel.None)
55 $
"Invalid FAUNA_DEBUG value of {level}; must be between 0 and 6 inclusive. Set to 0 for highest verbosity, default is 6 (no logging).");
58 minLogLevel = (LogLevel)level;
61 using ILoggerFactory factory = LoggerFactory.Create(builder => builder
62 .AddConsole(options => options.LogToStandardErrorThreshold = LogLevel.Trace)
63 .AddSimpleConsole(options =>
65 options.IncludeScopes =
true;
66 options.SingleLine =
true;
67 options.TimestampFormat =
"yyyy-MM-ddTHH:mm:ss.fffZ ";
68 options.UseUtcTimestamp =
true;
70 .SetMinimumLevel(minLogLevel));
72 return factory.CreateLogger(
"fauna-dotnet");
System.ArgumentException ArgumentException