using System; using System.Buffers; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Channels; using System.Threading.Tasks; using JetBrains.Annotations; using Serilog.Capturing; using Serilog.Configuration; using Serilog.Context; using Serilog.Core; using Serilog.Core.Enrichers; using Serilog.Core.Filters; using Serilog.Core.Pipeline; using Serilog.Core.Sinks; using Serilog.Core.Sinks.Batching; using Serilog.Data; using Serilog.Debugging; using Serilog.Events; using Serilog.Formatting.Json; using Serilog.Parsing; using Serilog.Policies; using Serilog.Rendering; using Serilog.Settings.KeyValuePairs; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: CLSCompliant(true)] [assembly: InternalsVisibleTo("Serilog.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100fb8d13fd344a1c6fe0fe83ef33c1080bf30690765bc6eb0df26ebfdf8f21670c64265b30db09f73a0dea5b3db4c9d18dbf6d5a25af5ce9016f281014d79dc3b4201ac646c451830fc7e61a2dfd633d34c39f87b81894191652df5ac63cc40c77f3542f702bda692e6e8a9158353df189007a49da0f3cfd55eb250066b19485ec")] [assembly: InternalsVisibleTo("Serilog.PerformanceTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100fb8d13fd344a1c6fe0fe83ef33c1080bf30690765bc6eb0df26ebfdf8f21670c64265b30db09f73a0dea5b3db4c9d18dbf6d5a25af5ce9016f281014d79dc3b4201ac646c451830fc7e61a2dfd633d34c39f87b81894191652df5ac63cc40c77f3542f702bda692e6e8a9158353df189007a49da0f3cfd55eb250066b19485ec")] [assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")] [assembly: AssemblyMetadata("IsTrimmable", "True")] [assembly: AssemblyCompany("Serilog Contributors")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2013-24 Serilog Contributors")] [assembly: AssemblyDescription("Simple .NET logging with fully-structured events")] [assembly: AssemblyFileVersion("4.0.0.0")] [assembly: AssemblyInformationalVersion("4.0.0-main-573a6287+573a62874260d7a1708f620076b5469f69bc79b3")] [assembly: AssemblyProduct("Serilog")] [assembly: AssemblyTitle("Serilog")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/serilog/serilog.git")] [assembly: AssemblyVersion("4.0.0.0")] [assembly: TypeForwardedTo(typeof(IsExternalInit))] [assembly: TypeForwardedTo(typeof(RequiresLocationAttribute))] [module: RefSafetyRules(11)] internal static class Guard { public static T AgainstNull([NoEnumeration][NotNull] T? argument, [CallerArgumentExpression("argument")] string? paramName = null) where T : class { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (argument == null) { throw new ArgumentNullException(paramName); } return argument; } } namespace JetBrains.Annotations { [AttributeUsage(/*Could not decode attribute arguments.*/)] internal sealed class NoEnumerationAttribute : System.Attribute { } } namespace Serilog { public interface ILogger { private static readonly object[] NoPropertyValues = System.Array.Empty(); private static readonly Logger DefaultLoggerImpl = new LoggerConfiguration().CreateLogger(); [CustomDefaultMethodImplementation] ILogger ForContext(ILogEventEnricher enricher) { return new LoggerConfiguration().MinimumLevel.Is(LogEventLevel.Verbose).WriteTo.Logger(this).CreateLogger().ForContext(enricher); } ILogger ForContext(System.Collections.Generic.IEnumerable enrichers) { if (enrichers == null) { return this; } return ForContext(new SafeAggregateEnricher(enrichers)); } [CustomDefaultMethodImplementation] ILogger ForContext(string propertyName, object? value, bool destructureObjects = false) { return new LoggerConfiguration().MinimumLevel.Is(LogEventLevel.Verbose).WriteTo.Logger(this).CreateLogger().ForContext(propertyName, value, destructureObjects); } ILogger ForContext() { return ForContext(typeof(TSource)); } ILogger ForContext(System.Type source) { if (source == (System.Type)null) { return this; } return ForContext("SourceContext", source.FullName); } void Write(LogEvent logEvent); [MessageTemplateFormatMethod("messageTemplate")] void Write(LogEventLevel level, string messageTemplate) { if (IsEnabled(level)) { Write(level, messageTemplate, NoPropertyValues); } } [MessageTemplateFormatMethod("messageTemplate")] void Write(LogEventLevel level, string messageTemplate, T propertyValue) { if (IsEnabled(level)) { Write(level, messageTemplate, new object[1] { propertyValue }); } } [MessageTemplateFormatMethod("messageTemplate")] void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { if (IsEnabled(level)) { Write(level, messageTemplate, new object[2] { propertyValue0, propertyValue1 }); } } [MessageTemplateFormatMethod("messageTemplate")] void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { if (IsEnabled(level)) { Write(level, messageTemplate, new object[3] { propertyValue0, propertyValue1, propertyValue2 }); } } [MessageTemplateFormatMethod("messageTemplate")] void Write(LogEventLevel level, string messageTemplate, params object?[]? propertyValues) { Write(level, (System.Exception?)null, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Write(LogEventLevel level, System.Exception? exception, string messageTemplate) { if (IsEnabled(level)) { Write(level, exception, messageTemplate, NoPropertyValues); } } [MessageTemplateFormatMethod("messageTemplate")] void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, T propertyValue) { if (IsEnabled(level)) { Write(level, exception, messageTemplate, new object[1] { propertyValue }); } } [MessageTemplateFormatMethod("messageTemplate")] void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { if (IsEnabled(level)) { Write(level, exception, messageTemplate, new object[2] { propertyValue0, propertyValue1 }); } } [MessageTemplateFormatMethod("messageTemplate")] void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { if (IsEnabled(level)) { Write(level, exception, messageTemplate, new object[3] { propertyValue0, propertyValue1, propertyValue2 }); } } [MessageTemplateFormatMethod("messageTemplate")] [CustomDefaultMethodImplementation] void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) if (IsEnabled(level) && messageTemplate != null) { if (propertyValues != null && ((object)propertyValues).GetType() != typeof(object[])) { propertyValues = new object[1] { propertyValues }; } DateTimeOffset now = DateTimeOffset.Now; if (BindMessageTemplate(messageTemplate, propertyValues, out MessageTemplate parsedTemplate, out System.Collections.Generic.IEnumerable boundProperties)) { Activity current = Activity.Current; LogEvent logEvent = new LogEvent(now, level, exception, parsedTemplate, boundProperties, (ActivityTraceId)((current != null) ? current.TraceId : default(ActivityTraceId)), (ActivitySpanId)((current != null) ? current.SpanId : default(ActivitySpanId))); Write(logEvent); } } } [CustomDefaultMethodImplementation] bool IsEnabled(LogEventLevel level) { return true; } [MessageTemplateFormatMethod("messageTemplate")] void Verbose(string messageTemplate) { Write(LogEventLevel.Verbose, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Verbose(string messageTemplate, T propertyValue) { Write(LogEventLevel.Verbose, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] void Verbose(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Verbose, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] void Verbose(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Verbose, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] void Verbose(string messageTemplate, params object?[]? propertyValues) { Verbose((System.Exception?)null, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Verbose(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Verbose, exception, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Verbose(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Verbose, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] void Verbose(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Verbose, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] void Verbose(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Verbose, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] void Verbose(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Write(LogEventLevel.Verbose, exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Debug(string messageTemplate) { Write(LogEventLevel.Debug, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Debug(string messageTemplate, T propertyValue) { Write(LogEventLevel.Debug, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] void Debug(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Debug, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] void Debug(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Debug, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] void Debug(string messageTemplate, params object?[]? propertyValues) { Debug((System.Exception?)null, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Debug(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Debug, exception, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Debug(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Debug, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] void Debug(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Debug, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] void Debug(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Debug, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] void Debug(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Write(LogEventLevel.Debug, exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Information(string messageTemplate) { Write(LogEventLevel.Information, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Information(string messageTemplate, T propertyValue) { Write(LogEventLevel.Information, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] void Information(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Information, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] void Information(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Information, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] void Information(string messageTemplate, params object?[]? propertyValues) { Information((System.Exception?)null, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Information(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Information, exception, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Information(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Information, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] void Information(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Information, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] void Information(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Information, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] void Information(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Write(LogEventLevel.Information, exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Warning(string messageTemplate) { Write(LogEventLevel.Warning, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Warning(string messageTemplate, T propertyValue) { Write(LogEventLevel.Warning, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] void Warning(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Warning, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] void Warning(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Warning, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] void Warning(string messageTemplate, params object?[]? propertyValues) { Warning((System.Exception?)null, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Warning(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Warning, exception, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Warning(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Warning, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] void Warning(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Warning, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] void Warning(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Warning, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] void Warning(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Write(LogEventLevel.Warning, exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Error(string messageTemplate) { Write(LogEventLevel.Error, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Error(string messageTemplate, T propertyValue) { Write(LogEventLevel.Error, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] void Error(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Error, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] void Error(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Error, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] void Error(string messageTemplate, params object?[]? propertyValues) { Error((System.Exception?)null, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Error(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Error, exception, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Error(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Error, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] void Error(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Error, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] void Error(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Error, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] void Error(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Write(LogEventLevel.Error, exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Fatal(string messageTemplate) { Write(LogEventLevel.Fatal, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Fatal(string messageTemplate, T propertyValue) { Write(LogEventLevel.Fatal, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] void Fatal(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Fatal, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] void Fatal(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Fatal, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] void Fatal(string messageTemplate, params object?[]? propertyValues) { Fatal((System.Exception?)null, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Fatal(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Fatal, exception, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] void Fatal(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Fatal, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] void Fatal(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Fatal, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] void Fatal(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Fatal, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] void Fatal(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Write(LogEventLevel.Fatal, exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] [CustomDefaultMethodImplementation] bool BindMessageTemplate(string messageTemplate, object?[]? propertyValues, [NotNullWhen(true)] out MessageTemplate? parsedTemplate, [NotNullWhen(true)] out System.Collections.Generic.IEnumerable? boundProperties) { return DefaultLoggerImpl.BindMessageTemplate(messageTemplate, propertyValues, out parsedTemplate, out boundProperties); } [CustomDefaultMethodImplementation] bool BindProperty(string? propertyName, object? value, bool destructureObjects, [NotNullWhen(true)] out LogEventProperty? property) { return DefaultLoggerImpl.BindProperty(propertyName, value, destructureObjects, out property); } } public static class Log { private static ILogger _logger = Serilog.Core.Logger.None; public static ILogger Logger { get { return _logger; } set { _logger = Guard.AgainstNull(value, "value"); } } public static void CloseAndFlush() { (Interlocked.Exchange(ref _logger, Serilog.Core.Logger.None) as System.IDisposable)?.Dispose(); } public static System.Threading.Tasks.ValueTask CloseAndFlushAsync() { return (Interlocked.Exchange(ref _logger, Serilog.Core.Logger.None) as System.IAsyncDisposable)?.DisposeAsync() ?? default(System.Threading.Tasks.ValueTask); } public static ILogger ForContext(ILogEventEnricher enricher) { return Logger.ForContext(enricher); } public static ILogger ForContext(ILogEventEnricher[] enrichers) { return Logger.ForContext(enrichers); } public static ILogger ForContext(string propertyName, object? value, bool destructureObjects = false) { return Logger.ForContext(propertyName, value, destructureObjects); } public static ILogger ForContext() { return Logger.ForContext(); } public static ILogger ForContext(System.Type source) { return Logger.ForContext(source); } public static void Write(LogEvent logEvent) { Logger.Write(logEvent); } [MessageTemplateFormatMethod("messageTemplate")] public static void Write(LogEventLevel level, string messageTemplate) { Logger.Write(level, messageTemplate); } [MessageTemplateFormatMethod("messageTemplate")] public static void Write(LogEventLevel level, string messageTemplate, T propertyValue) { Logger.Write(level, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public static void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Logger.Write(level, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public static void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Logger.Write(level, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public static void Write(LogEventLevel level, string messageTemplate, params object?[]? propertyValues) { Logger.Write(level, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public static void Write(LogEventLevel level, System.Exception? exception, string messageTemplate) { Logger.Write(level, exception, messageTemplate); } [MessageTemplateFormatMethod("messageTemplate")] public static void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, T propertyValue) { Logger.Write(level, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public static void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Logger.Write(level, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public static void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Logger.Write(level, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public static void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Logger.Write(level, exception, messageTemplate, propertyValues); } public static bool IsEnabled(LogEventLevel level) { return Logger.IsEnabled(level); } [MessageTemplateFormatMethod("messageTemplate")] public static void Verbose(string messageTemplate) { Write(LogEventLevel.Verbose, messageTemplate); } [MessageTemplateFormatMethod("messageTemplate")] public static void Verbose(string messageTemplate, T propertyValue) { Write(LogEventLevel.Verbose, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public static void Verbose(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Verbose, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public static void Verbose(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Verbose, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public static void Verbose(string messageTemplate, params object?[]? propertyValues) { Logger.Verbose(messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public static void Verbose(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Verbose, exception, messageTemplate); } [MessageTemplateFormatMethod("messageTemplate")] public static void Verbose(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Verbose, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public static void Verbose(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Verbose, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public static void Verbose(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Verbose, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public static void Verbose(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Logger.Verbose(exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public static void Debug(string messageTemplate) { Write(LogEventLevel.Debug, messageTemplate); } [MessageTemplateFormatMethod("messageTemplate")] public static void Debug(string messageTemplate, T propertyValue) { Write(LogEventLevel.Debug, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public static void Debug(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Debug, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public static void Debug(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Debug, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public static void Debug(string messageTemplate, params object?[]? propertyValues) { Logger.Debug(messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public static void Debug(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Debug, exception, messageTemplate); } [MessageTemplateFormatMethod("messageTemplate")] public static void Debug(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Debug, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public static void Debug(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Debug, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public static void Debug(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Debug, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public static void Debug(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Logger.Debug(exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public static void Information(string messageTemplate) { Write(LogEventLevel.Information, messageTemplate); } [MessageTemplateFormatMethod("messageTemplate")] public static void Information(string messageTemplate, T propertyValue) { Write(LogEventLevel.Information, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public static void Information(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Information, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public static void Information(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Information, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public static void Information(string messageTemplate, params object?[]? propertyValues) { Logger.Information(messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public static void Information(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Information, exception, messageTemplate); } [MessageTemplateFormatMethod("messageTemplate")] public static void Information(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Information, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public static void Information(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Information, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public static void Information(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Information, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public static void Information(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Logger.Information(exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public static void Warning(string messageTemplate) { Write(LogEventLevel.Warning, messageTemplate); } [MessageTemplateFormatMethod("messageTemplate")] public static void Warning(string messageTemplate, T propertyValue) { Write(LogEventLevel.Warning, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public static void Warning(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Warning, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public static void Warning(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Warning, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public static void Warning(string messageTemplate, params object?[]? propertyValues) { Logger.Warning(messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public static void Warning(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Warning, exception, messageTemplate); } [MessageTemplateFormatMethod("messageTemplate")] public static void Warning(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Warning, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public static void Warning(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Warning, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public static void Warning(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Warning, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public static void Warning(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Logger.Warning(exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public static void Error(string messageTemplate) { Write(LogEventLevel.Error, messageTemplate); } [MessageTemplateFormatMethod("messageTemplate")] public static void Error(string messageTemplate, T propertyValue) { Write(LogEventLevel.Error, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public static void Error(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Error, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public static void Error(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Error, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public static void Error(string messageTemplate, params object?[]? propertyValues) { Logger.Error(messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public static void Error(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Error, exception, messageTemplate); } [MessageTemplateFormatMethod("messageTemplate")] public static void Error(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Error, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public static void Error(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Error, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public static void Error(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Error, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public static void Error(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Logger.Error(exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public static void Fatal(string messageTemplate) { Write(LogEventLevel.Fatal, messageTemplate); } [MessageTemplateFormatMethod("messageTemplate")] public static void Fatal(string messageTemplate, T propertyValue) { Write(LogEventLevel.Fatal, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public static void Fatal(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Fatal, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public static void Fatal(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Fatal, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public static void Fatal(string messageTemplate, params object?[]? propertyValues) { Logger.Fatal(messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public static void Fatal(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Fatal, exception, messageTemplate); } [MessageTemplateFormatMethod("messageTemplate")] public static void Fatal(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Fatal, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public static void Fatal(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Fatal, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public static void Fatal(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Fatal, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public static void Fatal(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Logger.Fatal(exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public static bool BindMessageTemplate(string messageTemplate, object?[] propertyValues, [NotNullWhen(true)] out MessageTemplate? parsedTemplate, [NotNullWhen(true)] out System.Collections.Generic.IEnumerable? boundProperties) { return Logger.BindMessageTemplate(messageTemplate, propertyValues, out parsedTemplate, out boundProperties); } public static bool BindProperty(string propertyName, object? value, bool destructureObjects, [NotNullWhen(true)] out LogEventProperty? property) { return Logger.BindProperty(propertyName, value, destructureObjects, out property); } } public class LoggerConfiguration { [CompilerGenerated] private sealed class <>c__DisplayClass33_0 { public ILogEventSink[] disposableSinks; } private readonly List _logEventSinks = new List(); private readonly List _auditSinks = new List(); private readonly List _enrichers = new List(); private readonly List _filters = new List(); private readonly List _additionalScalarTypes = new List(); private readonly HashSet _additionalDictionaryTypes = new HashSet(); private readonly List _additionalDestructuringPolicies = new List(); private readonly Dictionary _overrides = new Dictionary(); private LogEventLevel _minimumLevel = LogEventLevel.Information; private LoggingLevelSwitch? _levelSwitch; private int _maximumDestructuringDepth = 10; private int _maximumStringLength = 2147483647; private int _maximumCollectionCount = 2147483647; private bool _loggerCreated; [field: CompilerGenerated] public LoggerSinkConfiguration WriteTo { [CompilerGenerated] get; [CompilerGenerated] internal set; } public LoggerAuditSinkConfiguration AuditTo => new LoggerAuditSinkConfiguration(this, [CompilerGenerated] (ILogEventSink s) => { _auditSinks.Add(s); }); public LoggerMinimumLevelConfiguration MinimumLevel => new LoggerMinimumLevelConfiguration(this, [CompilerGenerated] (LogEventLevel l) => { _minimumLevel = l; _levelSwitch = null; }, [CompilerGenerated] (LoggingLevelSwitch sw) => { _levelSwitch = sw; }, [CompilerGenerated] (string s, LoggingLevelSwitch lls) => { _overrides[s] = lls; }); [field: CompilerGenerated] public LoggerEnrichmentConfiguration Enrich { [CompilerGenerated] get; [CompilerGenerated] internal set; } public LoggerFilterConfiguration Filter => new LoggerFilterConfiguration(this, [CompilerGenerated] (ILogEventFilter f) => { _filters.Add(f); }); public LoggerDestructuringConfiguration Destructure { get { List additionalScalarTypes = _additionalScalarTypes; Action addScalar = additionalScalarTypes.Add; Action addDictionaryType = [CompilerGenerated] (System.Type type) => { _additionalDictionaryTypes.Add(type); }; List additionalDestructuringPolicies = _additionalDestructuringPolicies; return new LoggerDestructuringConfiguration(this, addScalar, addDictionaryType, additionalDestructuringPolicies.Add, [CompilerGenerated] (int depth) => { _maximumDestructuringDepth = depth; }, [CompilerGenerated] (int length) => { _maximumStringLength = length; }, [CompilerGenerated] (int count) => { _maximumCollectionCount = count; }); } } public LoggerSettingsConfiguration ReadFrom => new LoggerSettingsConfiguration(this); public LoggerConfiguration() { WriteTo = new LoggerSinkConfiguration(this, [CompilerGenerated] (ILogEventSink s) => { _logEventSinks.Add(s); }); Enrich = new LoggerEnrichmentConfiguration(this, [CompilerGenerated] (ILogEventEnricher e) => { _enrichers.Add(e); }); } public Logger CreateLogger() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown <>c__DisplayClass33_0 CS$<>8__locals0 = new <>c__DisplayClass33_0(); if (_loggerCreated) { throw new InvalidOperationException("CreateLogger() was previously called and can only be called once."); } _loggerCreated = true; ILogEventSink logEventSink = null; if (_logEventSinks.Count > 0) { logEventSink = new SafeAggregateSink((System.Collections.Generic.IEnumerable)_logEventSinks); } bool flag = Enumerable.Any((System.Collections.Generic.IEnumerable)_auditSinks); if (flag) { System.Collections.Generic.IEnumerable sinks; if (logEventSink != null) { sinks = Enumerable.Concat((System.Collections.Generic.IEnumerable)new ILogEventSink[1] { logEventSink }, (System.Collections.Generic.IEnumerable)_auditSinks); } else { System.Collections.Generic.IEnumerable auditSinks = (System.Collections.Generic.IEnumerable)_auditSinks; sinks = auditSinks; } logEventSink = new AggregateSink(sinks); } if (logEventSink == null) { logEventSink = new SafeAggregateSink(System.Array.Empty()); } if (Enumerable.Any((System.Collections.Generic.IEnumerable)_filters)) { logEventSink = new FilteringSink(logEventSink, (System.Collections.Generic.IEnumerable)_filters, flag); } MessageTemplateProcessor messageTemplateProcessor = new MessageTemplateProcessor(new PropertyValueConverter(_maximumDestructuringDepth, _maximumStringLength, _maximumCollectionCount, (System.Collections.Generic.IEnumerable)_additionalScalarTypes, (System.Collections.Generic.IEnumerable)_additionalDictionaryTypes, (System.Collections.Generic.IEnumerable)_additionalDestructuringPolicies, flag)); ILogEventEnricher enricher = _enrichers.Count switch { 0 => new EmptyEnricher(), 1 => _enrichers[0], _ => new SafeAggregateEnricher((System.Collections.Generic.IEnumerable)_enrichers), }; LevelOverrideMap overrideMap = null; if (_overrides.Count != 0) { overrideMap = new LevelOverrideMap((IDictionary)(object)_overrides, _minimumLevel, _levelSwitch); } CS$<>8__locals0.disposableSinks = Enumerable.ToArray(Enumerable.Where(Enumerable.Concat((System.Collections.Generic.IEnumerable)_logEventSinks, (System.Collections.Generic.IEnumerable)_auditSinks), (Func)((ILogEventSink s) => (s is System.IDisposable || s is System.IAsyncDisposable) ? true : false))); return new Logger(messageTemplateProcessor, (_levelSwitch == null) ? _minimumLevel : LogEventLevel.Verbose, _levelSwitch, logEventSink, enricher, new Action(Dispose), DisposeAsync, overrideMap); void Dispose() { ILogEventSink[] disposableSinks = CS$<>8__locals0.disposableSinks; for (int i = 0; i < disposableSinks.Length; i++) { (disposableSinks[i] as System.IDisposable)?.Dispose(); } } [AsyncStateMachine(typeof(<>c__DisplayClass33_0.<g__DisposeAsync|2>d))] System.Threading.Tasks.ValueTask DisposeAsync() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) <>c__DisplayClass33_0.<g__DisposeAsync|2>d <g__DisposeAsync|2>d = default(<>c__DisplayClass33_0.<g__DisposeAsync|2>d); <g__DisposeAsync|2>d.<>t__builder = AsyncValueTaskMethodBuilder.Create(); <g__DisposeAsync|2>d.<>4__this = CS$<>8__locals0; <g__DisposeAsync|2>d.<>1__state = -1; ((AsyncValueTaskMethodBuilder)(ref <g__DisposeAsync|2>d.<>t__builder)).Start<<>c__DisplayClass33_0.<g__DisposeAsync|2>d>(ref <g__DisposeAsync|2>d); return ((AsyncValueTaskMethodBuilder)(ref <g__DisposeAsync|2>d.<>t__builder)).Task; } } } public static class LoggerExtensions { public static ILogger ForContext(this ILogger logger, LogEventLevel level, string propertyName, TValue value, bool destructureObjects = false) { Guard.AgainstNull(logger, "logger"); if (!logger.IsEnabled(level)) { return logger; } return logger.ForContext(propertyName, value, destructureObjects); } } } namespace Serilog.Settings.KeyValuePairs { internal static class CallableConfigurationMethodFinder { [RequiresUnreferencedCode("Configuration methods are not trimming safe")] internal static System.Collections.Generic.IList FindConfigurationMethods(System.Collections.Generic.IEnumerable configurationAssemblies, System.Type configType) { System.Type configType2 = configType; List val = Enumerable.ToList(Enumerable.Where(Enumerable.SelectMany(Enumerable.SelectMany(configurationAssemblies, (Func>)([RequiresUnreferencedCode("Configuration methods are not trimming safe")] (Assembly a) => Enumerable.Where(a.ExportedTypes, (Func)((System.Type t) => t.IsSealed && t.IsAbstract && !t.IsNested)))), (Func>)((System.Type t) => t.GetMethods((BindingFlags)24))), (Func)((MethodInfo m) => ((MemberInfo)m).IsDefined(typeof(ExtensionAttribute), false) && ((MethodBase)m).GetParameters()[0].ParameterType == configType2))); if (configType2 == typeof(LoggerSinkConfiguration)) { val.AddRange((System.Collections.Generic.IEnumerable)SurrogateConfigurationMethods.WriteTo); } if (configType2 == typeof(LoggerAuditSinkConfiguration)) { val.AddRange((System.Collections.Generic.IEnumerable)SurrogateConfigurationMethods.AuditTo); } if (configType2 == typeof(LoggerEnrichmentConfiguration)) { val.AddRange((System.Collections.Generic.IEnumerable)SurrogateConfigurationMethods.Enrich); } if (configType2 == typeof(LoggerDestructuringConfiguration)) { val.AddRange((System.Collections.Generic.IEnumerable)SurrogateConfigurationMethods.Destructure); } if (configType2 == typeof(LoggerFilterConfiguration)) { val.AddRange((System.Collections.Generic.IEnumerable)SurrogateConfigurationMethods.Filter); } return (System.Collections.Generic.IList)val; } } [RequiresUnreferencedCode("Scans assemblies at runtime")] [RequiresDynamicCode("Creates arrays of unknown element type")] internal class KeyValuePairSettings : ILoggerSettings { internal class ConfigurationMethodCall { [field: CompilerGenerated] public string MethodName { [CompilerGenerated] get; } [field: CompilerGenerated] public string ArgumentName { [CompilerGenerated] get; } [field: CompilerGenerated] public string Value { [CompilerGenerated] get; } public ConfigurationMethodCall(string methodName, string argumentName, string value) { MethodName = methodName; ArgumentName = argumentName; Value = value; } } private const string UsingDirective = "using"; private const string LevelSwitchDirective = "level-switch"; private const string AuditToDirective = "audit-to"; private const string WriteToDirective = "write-to"; private const string MinimumLevelDirective = "minimum-level"; private const string MinimumLevelControlledByDirective = "minimum-level:controlled-by"; private const string EnrichWithDirective = "enrich"; private const string EnrichWithPropertyDirective = "enrich:with-property"; private const string FilterDirective = "filter"; private const string DestructureDirective = "destructure"; private const string UsingDirectiveFullFormPrefix = "using:"; private const string EnrichWithPropertyDirectivePrefix = "enrich:with-property:"; private const string MinimumLevelOverrideDirectivePrefix = "minimum-level:override:"; private const string CallableDirectiveRegex = "^(?audit-to|write-to|enrich|filter|destructure):(?[A-Za-z0-9]*)(\\.(?[A-Za-z0-9]*)){0,1}$"; private const string LevelSwitchDeclarationDirectiveRegex = "^level-switch:(?.*)$"; private const string LevelSwitchNameRegex = "^\\$[A-Za-z]+[A-Za-z0-9]*$"; private static readonly string[] _supportedDirectives = new string[10] { "using", "level-switch", "audit-to", "write-to", "minimum-level", "minimum-level:controlled-by", "enrich:with-property", "enrich", "filter", "destructure" }; private static readonly Dictionary CallableDirectiveReceiverTypes = new Dictionary { ["audit-to"] = typeof(LoggerAuditSinkConfiguration), ["write-to"] = typeof(LoggerSinkConfiguration), ["enrich"] = typeof(LoggerEnrichmentConfiguration), ["filter"] = typeof(LoggerFilterConfiguration), ["destructure"] = typeof(LoggerDestructuringConfiguration) }; private static readonly Dictionary> CallableDirectiveReceivers = new Dictionary> { [typeof(LoggerAuditSinkConfiguration)] = (LoggerConfiguration lc) => lc.AuditTo, [typeof(LoggerSinkConfiguration)] = (LoggerConfiguration lc) => lc.WriteTo, [typeof(LoggerEnrichmentConfiguration)] = (LoggerConfiguration lc) => lc.Enrich, [typeof(LoggerFilterConfiguration)] = (LoggerConfiguration lc) => lc.Filter, [typeof(LoggerDestructuringConfiguration)] = (LoggerConfiguration lc) => lc.Destructure }; private readonly IReadOnlyDictionary _settings; [RequiresUnreferencedCode("Finds accessors by name")] public KeyValuePairSettings(IReadOnlyDictionary settings) { _settings = Guard.AgainstNull>(settings, "settings"); } public void Configure(LoggerConfiguration loggerConfiguration) { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Expected O, but got Unknown Guard.AgainstNull(loggerConfiguration, "loggerConfiguration"); Dictionary val = Enumerable.ToDictionary, string, string>(Enumerable.Where>((System.Collections.Generic.IEnumerable>)_settings, (Func, bool>)((KeyValuePair kvp) => Enumerable.Any((System.Collections.Generic.IEnumerable)_supportedDirectives, (Func)kvp.Key.StartsWith))), (Func, string>)((KeyValuePair kvp) => kvp.Key), (Func, string>)((KeyValuePair kvp) => kvp.Value)); IReadOnlyDictionary val2 = ParseNamedLevelSwitchDeclarationDirectives((IReadOnlyDictionary)(object)val); string text = default(string); LogEventLevel minimumLevel = default(LogEventLevel); if (val.TryGetValue("minimum-level", ref text) && System.Enum.TryParse(text, ref minimumLevel)) { loggerConfiguration.MinimumLevel.Is(minimumLevel); } System.Collections.Generic.IEnumerator> enumerator = Enumerable.Where>((System.Collections.Generic.IEnumerable>)val, (Func, bool>)((KeyValuePair dir) => dir.Key.StartsWith("enrich:with-property:") && dir.Key.Length > "enrich:with-property:".Length)).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { KeyValuePair current = enumerator.Current; string name = current.Key.Substring("enrich:with-property:".Length); loggerConfiguration.Enrich.WithProperty(name, current.Value); } } finally { ((System.IDisposable)enumerator)?.Dispose(); } string switchName = default(string); if (val.TryGetValue("minimum-level:controlled-by", ref switchName)) { LoggingLevelSwitch levelSwitch = LookUpSwitchByName(switchName, val2); loggerConfiguration.MinimumLevel.ControlledBy(levelSwitch); } enumerator = Enumerable.Where>((System.Collections.Generic.IEnumerable>)val, (Func, bool>)((KeyValuePair dir) => dir.Key.StartsWith("minimum-level:override:") && dir.Key.Length > "minimum-level:override:".Length)).GetEnumerator(); try { LogEventLevel minimumLevel2 = default(LogEventLevel); while (((System.Collections.IEnumerator)enumerator).MoveNext()) { KeyValuePair current2 = enumerator.Current; string source = current2.Key.Substring("minimum-level:override:".Length); if (System.Enum.TryParse(current2.Value, ref minimumLevel2)) { loggerConfiguration.MinimumLevel.Override(source, minimumLevel2); continue; } LoggingLevelSwitch levelSwitch2 = LookUpSwitchByName(current2.Value, val2); loggerConfiguration.MinimumLevel.Override(source, levelSwitch2); } } finally { ((System.IDisposable)enumerator)?.Dispose(); } Regex matchCallables = new Regex("^(?audit-to|write-to|enrich|filter|destructure):(?[A-Za-z0-9]*)(\\.(?[A-Za-z0-9]*)){0,1}$"); var val3 = Enumerable.ToList(Enumerable.Select(Enumerable.Select(Enumerable.Where>((System.Collections.Generic.IEnumerable>)val, (Func, bool>)delegate(KeyValuePair wt) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) Regex obj2 = matchCallables; KeyValuePair val5 = wt; return obj2.IsMatch(val5.Key); }), delegate(KeyValuePair wt) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Regex obj = matchCallables; KeyValuePair val4 = wt; return new { wt = wt, match = obj.Match(val4.Key) }; }), <>h__TransparentIdentifier0 => new { ReceiverType = CallableDirectiveReceiverTypes[((Capture)<>h__TransparentIdentifier0.match.Groups["directive"]).Value], Call = new ConfigurationMethodCall(((Capture)<>h__TransparentIdentifier0.match.Groups["method"]).Value, ((Capture)<>h__TransparentIdentifier0.match.Groups["argument"]).Value, <>h__TransparentIdentifier0.wt.Value) })); if (!Enumerable.Any((System.Collections.Generic.IEnumerable<<>f__AnonymousType1>)val3)) { return; } List configurationAssemblies = Enumerable.ToList(LoadConfigurationAssemblies((IReadOnlyDictionary)(object)val)); var enumerator2 = Enumerable.GroupBy((System.Collections.Generic.IEnumerable<<>f__AnonymousType1>)val3, d => d.ReceiverType).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator2).MoveNext()) { var current3 = enumerator2.Current; System.Collections.Generic.IList configurationMethods = CallableConfigurationMethodFinder.FindConfigurationMethods((System.Collections.Generic.IEnumerable)configurationAssemblies, current3.Key); ApplyDirectives(Enumerable.ToList>(Enumerable.GroupBy(Enumerable.Select((System.Collections.Generic.IEnumerable<<>f__AnonymousType1>)current3, d => d.Call), (Func)((ConfigurationMethodCall call) => call.MethodName))), configurationMethods, CallableDirectiveReceivers[current3.Key].Invoke(loggerConfiguration), val2); } } finally { ((System.IDisposable)enumerator2)?.Dispose(); } } internal static bool IsValidSwitchName(string input) { return Regex.IsMatch(input, "^\\$[A-Za-z]+[A-Za-z0-9]*$"); } [RequiresUnreferencedCode("Reflects against accessors using dynamic string")] private static IReadOnlyDictionary ParseNamedLevelSwitchDeclarationDirectives(IReadOnlyDictionary directives) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) Regex matchLevelSwitchDeclarations = new Regex("^level-switch:(?.*)$"); var obj = Enumerable.ToList(Enumerable.Select(Enumerable.Select(Enumerable.Where>((System.Collections.Generic.IEnumerable>)directives, (Func, bool>)delegate(KeyValuePair wt) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) Regex obj3 = matchLevelSwitchDeclarations; KeyValuePair val3 = wt; return obj3.IsMatch(val3.Key); }), delegate(KeyValuePair wt) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Regex obj2 = matchLevelSwitchDeclarations; KeyValuePair val2 = wt; return new { wt = wt, match = obj2.Match(val2.Key) }; }), <>h__TransparentIdentifier0 => new { SwitchName = ((Capture)<>h__TransparentIdentifier0.match.Groups["switchName"]).Value, InitialSwitchLevel = <>h__TransparentIdentifier0.wt.Value })); Dictionary val = new Dictionary(); var enumerator = obj.GetEnumerator(); try { while (enumerator.MoveNext()) { var current = enumerator.Current; string switchName = current.SwitchName; string initialSwitchLevel = current.InitialSwitchLevel; if (!IsValidSwitchName(switchName)) { throw new FormatException("\"" + switchName + "\" is not a valid name for a Level Switch declaration. Level switch must be declared with a '$' sign, like \"level-switch:$switchName\""); } LoggingLevelSwitch loggingLevelSwitch = ((!(initialSwitchLevel == string.Empty)) ? new LoggingLevelSwitch((LogEventLevel)System.Enum.Parse(typeof(LogEventLevel), initialSwitchLevel)) : new LoggingLevelSwitch()); val.Add(switchName, loggingLevelSwitch); } return (IReadOnlyDictionary)(object)val; } finally { ((System.IDisposable)enumerator).Dispose(); } } private static LoggingLevelSwitch LookUpSwitchByName(string switchName, IReadOnlyDictionary declaredLevelSwitches) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) LoggingLevelSwitch result = default(LoggingLevelSwitch); if (declaredLevelSwitches.TryGetValue(switchName, ref result)) { return result; } throw new InvalidOperationException($"No LoggingLevelSwitch has been declared with name \"{switchName}\". You might be missing a key \"{"level-switch"}:{switchName}\""); } [RequiresUnreferencedCode("Finds accessors by name")] [RequiresDynamicCode("Creates arrays of unknown element type")] private static object ConvertOrLookupByName(string valueOrSwitchName, System.Type type, IReadOnlyDictionary declaredSwitches) { if (type == typeof(LoggingLevelSwitch)) { return LookUpSwitchByName(valueOrSwitchName, declaredSwitches); } return SettingValueConversions.ConvertToType(valueOrSwitchName, type); } [RequiresUnreferencedCode("Finds accessors by name")] [RequiresDynamicCode("Creates arrays of unknown element type")] private static void ApplyDirectives(List> directives, System.Collections.Generic.IList configurationMethods, object loggerConfigMethod, IReadOnlyDictionary declaredSwitches) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) IReadOnlyDictionary declaredSwitches2 = declaredSwitches; Enumerator> enumerator = directives.GetEnumerator(); try { while (enumerator.MoveNext()) { IGrouping directiveInfo = enumerator.Current; MethodInfo val = SelectConfigurationMethod((System.Collections.Generic.IEnumerable)configurationMethods, directiveInfo.Key, (System.Collections.Generic.IEnumerable)directiveInfo); if (val == (MethodInfo)null) { SelfLog.WriteLine("Setting \"{0}\" could not be matched to an implementation in any of the loaded assemblies. To use settings from additional assemblies, specify them with the \"serilog:using\" key.", directiveInfo.Key); continue; } List val2 = Enumerable.ToList(Enumerable.Select(Enumerable.Select(Enumerable.Skip((System.Collections.Generic.IEnumerable)((MethodBase)val).GetParameters(), 1), (ParameterInfo p) => new { p = p, directive = Enumerable.FirstOrDefault((System.Collections.Generic.IEnumerable)directiveInfo, (Func)((ConfigurationMethodCall s) => s.ArgumentName == p.Name)) }), <>h__TransparentIdentifier0 => SuppressConvertCall(<>h__TransparentIdentifier0.directive, <>h__TransparentIdentifier0.p))); val2.Insert(0, loggerConfigMethod); ((MethodBase)val).Invoke((object)null, val2.ToArray()); } } finally { ((System.IDisposable)enumerator).Dispose(); } [UnconditionalSuppressMessage("Trimming", "IL2026")] [UnconditionalSuppressMessage("AOT", "IL3050")] object? SuppressConvertCall(ConfigurationMethodCall? directive, ParameterInfo p) { if (directive != null) { return ConvertOrLookupByName(directive.Value, p.ParameterType, declaredSwitches2); } return p.DefaultValue; } } internal static MethodInfo? SelectConfigurationMethod(System.Collections.Generic.IEnumerable candidateMethods, string name, System.Collections.Generic.IEnumerable suppliedArgumentValues) { string name2 = name; System.Collections.Generic.IEnumerable suppliedArgumentValues2 = suppliedArgumentValues; return Enumerable.FirstOrDefault((System.Collections.Generic.IEnumerable)Enumerable.OrderByDescending(Enumerable.Where(candidateMethods, (Func)((MethodInfo m) => ((MemberInfo)m).Name == name2 && Enumerable.All(Enumerable.Skip((System.Collections.Generic.IEnumerable)((MethodBase)m).GetParameters(), 1), (Func)((ParameterInfo p) => p.HasDefaultValue || Enumerable.Any(suppliedArgumentValues2, (Func)((ConfigurationMethodCall s) => s.ArgumentName == p.Name)))))), (Func)((MethodInfo m) => Enumerable.Count((System.Collections.Generic.IEnumerable)((MethodBase)m).GetParameters(), (Func)((ParameterInfo p) => Enumerable.Any(suppliedArgumentValues2, (Func)((ConfigurationMethodCall s) => s.ArgumentName == p.Name))))))); } internal static System.Collections.Generic.IEnumerable LoadConfigurationAssemblies(IReadOnlyDictionary directives) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) List obj = new List(); obj.Add(typeof(ILogger).Assembly); List val = obj; System.Collections.Generic.IEnumerator> enumerator = Enumerable.Where>((System.Collections.Generic.IEnumerable>)directives, (Func, bool>)((KeyValuePair d) => d.Key.Equals("using") || d.Key.StartsWith("using:"))).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { KeyValuePair current = enumerator.Current; if (string.IsNullOrWhiteSpace(current.Value)) { throw new InvalidOperationException("A zero-length or whitespace assembly name was supplied to a serilog:using configuration statement."); } AssemblyName val2 = new AssemblyName(current.Value); val.Add(Assembly.Load(val2)); } } finally { ((System.IDisposable)enumerator)?.Dispose(); } return Enumerable.Distinct((System.Collections.Generic.IEnumerable)val); } } internal class SettingValueConversions { private static Regex StaticMemberAccessorRegex = new Regex("^(?[^:]+)::(?[A-Za-z][A-Za-z0-9]*)(?[^:]*)$"); private static Dictionary> ExtendedTypeConversions; [RequiresUnreferencedCode("Finds accessors by name")] [RequiresDynamicCode("Creates arrays of unknown element type")] public static object? ConvertToType(string value, System.Type toType) { //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) System.Type toType2 = toType; if (toType2.IsGenericType && toType2.GetGenericTypeDefinition() == typeof(System.Nullable<>)) { if (value == string.Empty) { return null; } toType2 = toType2.GenericTypeArguments[0]; } if (toType2.IsEnum) { return System.Enum.Parse(toType2, value); } Func val = Enumerable.FirstOrDefault>(Enumerable.Select>, Func>(Enumerable.Where>>((System.Collections.Generic.IEnumerable>>)ExtendedTypeConversions, (Func>, bool>)((KeyValuePair> t) => t.Key.IsAssignableFrom(toType2))), (Func>, Func>)((KeyValuePair> t) => t.Value))); if (val != null) { return val.Invoke(value); } if ((toType2.IsInterface || toType2.IsAbstract) && !string.IsNullOrWhiteSpace(value)) { if (TryParseStaticMemberAccessor(value, out string accessorTypeName, out string memberName)) { System.Type type = System.Type.GetType(accessorTypeName, true); PropertyInfo val2 = Enumerable.FirstOrDefault((System.Collections.Generic.IEnumerable)type.GetProperties((BindingFlags)24), (Func)((PropertyInfo x) => ((MemberInfo)x).Name == memberName && x.GetMethod != (MethodInfo)null)); if (val2 != (PropertyInfo)null) { return val2.GetValue((object)null); } FieldInfo val3 = Enumerable.FirstOrDefault((System.Collections.Generic.IEnumerable)type.GetFields((BindingFlags)24), (Func)((FieldInfo x) => ((MemberInfo)x).Name == memberName)); if (val3 != (FieldInfo)null) { return val3.GetValue((object)null); } throw new InvalidOperationException($"Could not find a public static property or field with name `{memberName}` on type `{accessorTypeName}`"); } System.Type type2 = System.Type.GetType(value.Trim(), false); if (type2 != (System.Type)null) { ConstructorInfo obj = Enumerable.FirstOrDefault((System.Collections.Generic.IEnumerable)type2.GetConstructors((BindingFlags)20), (Func)delegate(ConstructorInfo ci) { ParameterInfo[] parameters = ((MethodBase)ci).GetParameters(); return parameters.Length == 0 || Enumerable.All((System.Collections.Generic.IEnumerable)parameters, (Func)((ParameterInfo pi) => pi.HasDefaultValue)); }); if (obj == (ConstructorInfo)null) { throw new InvalidOperationException("A default constructor was not found on " + type2.FullName + "."); } object[] array = Enumerable.ToArray(Enumerable.Select((System.Collections.Generic.IEnumerable)((MethodBase)obj).GetParameters(), (Func)((ParameterInfo pi) => pi.DefaultValue))); return obj.Invoke(array); } } if (toType2.IsArray && toType2.GetArrayRank() == 1) { System.Type elementType = toType2.GetElementType(); if (string.IsNullOrEmpty(value)) { return System.Array.CreateInstance(elementType, 0); } string[] array2 = value.Split(',', (StringSplitOptions)0); int num = array2.Length; System.Array array3 = System.Array.CreateInstance(elementType, array2.Length); for (int i = 0; i < num; i++) { object obj2 = ConvertToType(array2[i], elementType); array3.SetValue(obj2, i); } return array3; } return Convert.ChangeType((object)value, toType2); } internal static bool TryParseStaticMemberAccessor(string input, [NotNullWhen(true)] out string? accessorTypeName, [NotNullWhen(true)] out string? memberName) { if (StaticMemberAccessorRegex.IsMatch(input)) { Match obj = StaticMemberAccessorRegex.Match(input); string value = ((Capture)obj.Groups["shortTypeName"]).Value; string value2 = ((Capture)obj.Groups["memberName"]).Value; string value3 = ((Capture)obj.Groups["typeNameExtraQualifiers"]).Value; memberName = value2.Trim(); accessorTypeName = value.Trim() + value3.TrimEnd(); return true; } accessorTypeName = null; memberName = null; return false; } static SettingValueConversions() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown Dictionary> obj = new Dictionary>(); obj.Add(typeof(Uri), (Func)((string s) => (object)new Uri(s))); obj.Add(typeof(TimeSpan), (Func)((string s) => TimeSpan.Parse(s))); obj.Add(typeof(System.Type), (Func)([UnconditionalSuppressMessage("Trimming", "IL2057")] (string s) => System.Type.GetType(s, true))); ExtendedTypeConversions = obj; } } internal static class SurrogateConfigurationMethods { private static readonly Dictionary SurrogateMethodCandidates = Enumerable.ToDictionary, System.Type, MethodInfo[]>(Enumerable.GroupBy(IntrospectionExtensions.GetTypeInfo(typeof(SurrogateConfigurationMethods)).DeclaredMethods, (Func)((MethodInfo m) => Enumerable.First((System.Collections.Generic.IEnumerable)((MethodBase)m).GetParameters()).ParameterType)), (Func, System.Type>)((IGrouping g) => g.Key), (Func, MethodInfo[]>)((IGrouping g) => Enumerable.ToArray((System.Collections.Generic.IEnumerable)g))); internal static readonly MethodInfo[] WriteTo = SurrogateMethodCandidates[typeof(LoggerSinkConfiguration)]; internal static readonly MethodInfo[] AuditTo = SurrogateMethodCandidates[typeof(LoggerAuditSinkConfiguration)]; internal static readonly MethodInfo[] Enrich = SurrogateMethodCandidates[typeof(LoggerEnrichmentConfiguration)]; internal static readonly MethodInfo[] Destructure = SurrogateMethodCandidates[typeof(LoggerDestructuringConfiguration)]; internal static readonly MethodInfo[] Filter = SurrogateMethodCandidates[typeof(LoggerFilterConfiguration)]; internal static LoggerConfiguration Sink(LoggerSinkConfiguration loggerSinkConfiguration, ILogEventSink sink, LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose, LoggingLevelSwitch? levelSwitch = null) { return loggerSinkConfiguration.Sink(sink, restrictedToMinimumLevel, levelSwitch); } internal static LoggerConfiguration Sink(LoggerAuditSinkConfiguration auditSinkConfiguration, ILogEventSink sink, LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose, LoggingLevelSwitch? levelSwitch = null) { return auditSinkConfiguration.Sink(sink, restrictedToMinimumLevel, levelSwitch); } internal static LoggerConfiguration With(LoggerEnrichmentConfiguration loggerEnrichmentConfiguration, ILogEventEnricher enricher) { return loggerEnrichmentConfiguration.With(enricher); } internal static LoggerConfiguration FromLogContext(LoggerEnrichmentConfiguration loggerEnrichmentConfiguration) { return loggerEnrichmentConfiguration.FromLogContext(); } internal static LoggerConfiguration With(LoggerDestructuringConfiguration loggerDestructuringConfiguration, IDestructuringPolicy policy) { return loggerDestructuringConfiguration.With(policy); } internal static LoggerConfiguration AsScalar(LoggerDestructuringConfiguration loggerDestructuringConfiguration, System.Type scalarType) { return loggerDestructuringConfiguration.AsScalar(scalarType); } internal static LoggerConfiguration ToMaximumCollectionCount(LoggerDestructuringConfiguration loggerDestructuringConfiguration, int maximumCollectionCount) { return loggerDestructuringConfiguration.ToMaximumCollectionCount(maximumCollectionCount); } internal static LoggerConfiguration ToMaximumDepth(LoggerDestructuringConfiguration loggerDestructuringConfiguration, int maximumDestructuringDepth) { return loggerDestructuringConfiguration.ToMaximumDepth(maximumDestructuringDepth); } internal static LoggerConfiguration ToMaximumStringLength(LoggerDestructuringConfiguration loggerDestructuringConfiguration, int maximumStringLength) { return loggerDestructuringConfiguration.ToMaximumStringLength(maximumStringLength); } internal static LoggerConfiguration With(LoggerFilterConfiguration loggerFilterConfiguration, ILogEventFilter filter) { return loggerFilterConfiguration.With(filter); } } } namespace Serilog.Rendering { internal static class Casing { public static string Format(string value, string? format = null) { if (!(format == "u")) { if (format == "w") { return value.ToLowerInvariant(); } return value; } return value.ToUpperInvariant(); } } internal static class MessageTemplateRenderer { private static readonly JsonValueFormatter JsonValueFormatter = new JsonValueFormatter("$type"); [MethodImpl(256)] public static void Render(MessageTemplate messageTemplate, IReadOnlyDictionary properties, TextWriter output, string? format = null, IFormatProvider? formatProvider = null) { bool isLiteral = false; bool isJson = false; if (format != null) { for (int i = 0; i < format.Length; i++) { if (format[i] == 'l') { isLiteral = true; } else if (format[i] == 'j') { isJson = true; } } } for (int j = 0; j < messageTemplate.TokenArray.Length; j++) { MessageTemplateToken messageTemplateToken = messageTemplate.TokenArray[j]; if (messageTemplateToken is TextToken tt) { RenderTextToken(tt, output); } else { RenderPropertyToken((PropertyToken)messageTemplateToken, properties, output, formatProvider, isLiteral, isJson); } } } public static void RenderTextToken(TextToken tt, TextWriter output) { output.Write(tt.Text); } public static void RenderPropertyToken(PropertyToken pt, IReadOnlyDictionary properties, TextWriter output, IFormatProvider? formatProvider, bool isLiteral, bool isJson) { LogEventPropertyValue propertyValue = default(LogEventPropertyValue); if (!properties.TryGetValue(pt.PropertyName, ref propertyValue)) { output.Write(pt.RawText); return; } if (!pt.Alignment.HasValue) { RenderValue(propertyValue, isLiteral, isJson, output, pt.Format, formatProvider); return; } StringWriter orCreate = ReusableStringWriter.GetOrCreate(); try { RenderValue(propertyValue, isLiteral, isJson, (TextWriter)(object)orCreate, pt.Format, formatProvider); StringBuilder stringBuilder = orCreate.GetStringBuilder(); if (stringBuilder.Length >= pt.Alignment.Value.Width) { output.Write(stringBuilder); return; } Alignment? alignment = pt.Alignment.Value; Padding.Apply(output, stringBuilder, in alignment); } finally { ((System.IDisposable)orCreate)?.Dispose(); } } private static void RenderValue(LogEventPropertyValue propertyValue, bool literal, bool json, TextWriter output, string? format, IFormatProvider? formatProvider) { if (literal && propertyValue is ScalarValue scalarValue && scalarValue.Value is string text) { output.Write(text); } else if (json && format == null) { JsonValueFormatter.Format(propertyValue, output); } else { propertyValue.Render(output, format, formatProvider); } } } internal static class Padding { private static readonly char[] PaddingChars = Enumerable.ToArray(Enumerable.Repeat(' ', 80)); public static void Apply(TextWriter output, string value, in Alignment? alignment) { if (!alignment.HasValue || value.Length >= alignment.Value.Width) { output.Write(value); return; } int num = alignment.Value.Width - value.Length; if (alignment.Value.Direction == AlignmentDirection.Left) { output.Write(value); } if (num <= PaddingChars.Length) { output.Write(PaddingChars, 0, num); } else { output.Write(new string(' ', num)); } if (alignment.Value.Direction == AlignmentDirection.Right) { output.Write(value); } } public static void Apply(TextWriter output, StringBuilder value, in Alignment? alignment) { if (!alignment.HasValue || value.Length >= alignment.Value.Width) { output.Write(value); return; } int num = alignment.Value.Width - value.Length; if (alignment.Value.Direction == AlignmentDirection.Left) { output.Write(value); } if (num <= PaddingChars.Length) { output.Write(PaddingChars, 0, num); } else { output.Write(new string(' ', num)); } if (alignment.Value.Direction == AlignmentDirection.Right) { output.Write(value); } } } internal class ReusableStringWriter : StringWriter { [ThreadStatic] private static ReusableStringWriter? _pooledWriter; internal const int StringBuilderCapacityThreshold = 32768; public static StringWriter GetOrCreate(IFormatProvider? formatProvider = null) { IFormatProvider val = (IFormatProvider)(((object)formatProvider) ?? ((object)CultureInfo.CurrentCulture)); ReusableStringWriter reusableStringWriter = _pooledWriter; _pooledWriter = null; if (reusableStringWriter == null || !object.Equals((object)((TextWriter)reusableStringWriter).FormatProvider, (object)val)) { reusableStringWriter = new ReusableStringWriter(formatProvider); } return (StringWriter)(object)reusableStringWriter; } private ReusableStringWriter(IFormatProvider? formatProvider) : base((IFormatProvider)(((object)formatProvider) ?? ((object)CultureInfo.CurrentCulture))) { } protected override void Dispose(bool disposing) { if (!disposing) { ((StringWriter)this).Dispose(disposing); return; } StringBuilder stringBuilder = ((StringWriter)this).GetStringBuilder(); if (stringBuilder.Capacity > 32768) { ((StringWriter)this).Dispose(disposing); return; } stringBuilder.Clear(); _pooledWriter = this; } } } namespace Serilog.Policies { internal class ByteArrayScalarConversionPolicy : IScalarConversionPolicy { private const int MaximumByteArrayLength = 1024; public bool TryConvertToScalar(object value, [NotNullWhen(true)] out ScalarValue? result) { if (!(value is byte[] array)) { result = null; return false; } if (array.Length > 1024) { string value2 = Convert.ToHexString(array, 0, 16) + "... (" + array.Length + " bytes)"; result = new ScalarValue(value2); } else { result = new ScalarValue(Convert.ToHexString(array)); } return true; } } internal sealed class ByteMemoryScalarConversionPolicy : IScalarConversionPolicy { private const int MaximumByteArrayLength = 1024; private const int MaxTake = 16; public bool TryConvertToScalar(object value, [NotNullWhen(true)] out ScalarValue? result) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (value is ReadOnlyMemory bytes) { result = new ScalarValue(ConvertToHexString(bytes)); return true; } if (value is System.Memory memory) { result = new ScalarValue(ConvertToHexString(System.Memory.op_Implicit(memory))); return true; } result = null; return false; } private static string ConvertToHexString(ReadOnlyMemory bytes) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (bytes.Length > 1024) { return ConvertToHexString(bytes.Slice(0, 16), $"... ({bytes.Length} bytes)"); } return ConvertToHexString(bytes, ""); } private unsafe static string ConvertToHexString(ReadOnlyMemory src, string tail) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) return string.Create, string>>(src.Length * 2 + tail.Length, new ValueTuple, string>(src, tail), (SpanAction, string>>)delegate(System.Span dest, ValueTuple, string> state) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) ValueTuple, string> val = state; ReadOnlyMemory item = val.Item1; string item2 = val.Item2; System.ReadOnlySpan span = item.Span; int num = default(int); for (int i = 0; i < span.Length; i++) { byte b = *(byte*)span[i]; if (b.TryFormat(dest, ref num, string.op_Implicit("X2"), (IFormatProvider)null)) { int num2 = num; dest = dest.Slice(num2, dest.Length - num2); } } for (int j = 0; j < item2.Length; j++) { dest[j] = item2[j]; } }); } } internal class DelegateDestructuringPolicy : IDestructuringPolicy { public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory, [NotNullWhen(true)] out LogEventPropertyValue? result) { if (value is System.Delegate @delegate) { result = new ScalarValue(((object)@delegate).ToString()); return true; } result = null; return false; } } internal class EnumScalarConversionPolicy : IScalarConversionPolicy { public bool TryConvertToScalar(object value, [NotNullWhen(true)] out ScalarValue? result) { if (value is System.Enum) { result = new ScalarValue(value); return true; } result = null; return false; } } internal class PrimitiveScalarConversionPolicy : IScalarConversionPolicy { public bool TryConvertToScalar(object value, [NotNullWhen(true)] out ScalarValue? result) { if (value.GetType().IsPrimitive) { result = new ScalarValue(value); return true; } result = null; return false; } } internal class ProjectedDestructuringPolicy : IDestructuringPolicy { private readonly Func _canApply; private readonly Func _projection; public ProjectedDestructuringPolicy(Func canApply, Func projection) { _canApply = Guard.AgainstNull>(canApply, "canApply"); _projection = Guard.AgainstNull>(projection, "projection"); } public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory, [NotNullWhen(true)] out LogEventPropertyValue? result) { Guard.AgainstNull(value, "value"); if (!_canApply.Invoke(value.GetType())) { result = null; return false; } object value2 = _projection.Invoke(value); result = propertyValueFactory.CreatePropertyValue(value2, destructureObjects: true); return true; } } internal class ReflectionTypesScalarDestructuringPolicy : IDestructuringPolicy { public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory, [NotNullWhen(true)] out LogEventPropertyValue? result) { if ((value is System.Type || value is MemberInfo) ? true : false) { result = new ScalarValue(value); return true; } result = null; return false; } } internal class SimpleScalarConversionPolicy : IScalarConversionPolicy { private readonly HashSet _scalarTypes; public SimpleScalarConversionPolicy(System.Collections.Generic.IEnumerable scalarTypes) { HashSet val = new HashSet(); System.Collections.Generic.IEnumerator enumerator = scalarTypes.GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { System.Type current = enumerator.Current; val.Add(current); } } finally { ((System.IDisposable)enumerator)?.Dispose(); } _scalarTypes = val; } public bool TryConvertToScalar(object value, [NotNullWhen(true)] out ScalarValue? result) { if (_scalarTypes.Contains(value.GetType())) { result = new ScalarValue(value); return true; } result = null; return false; } } } namespace Serilog.Parsing { public readonly struct Alignment { [field: CompilerGenerated] public AlignmentDirection Direction { [CompilerGenerated] get; } [field: CompilerGenerated] public int Width { [CompilerGenerated] get; } public Alignment(AlignmentDirection direction, int width) { Direction = direction; Width = width; } } public enum AlignmentDirection { Left, Right } public enum Destructuring { Default, Stringify, Destructure } public class MessageTemplateParser : IMessageTemplateParser { [CompilerGenerated] private sealed class d__6 : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator, System.Collections.IEnumerator, System.IDisposable { private int <>1__state; private MessageTemplateToken <>2__current; private int <>l__initialThreadId; private string messageTemplate; public string <>3__messageTemplate; public MessageTemplateParser <>4__this; private int 5__2; MessageTemplateToken System.Collections.Generic.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void System.IDisposable.Dispose() { } private bool MoveNext() { int num = <>1__state; MessageTemplateParser messageTemplateParser = <>4__this; int num2; MessageTemplateToken messageTemplateToken; int num3; TextToken textToken; switch (num) { default: return false; case 0: <>1__state = -1; if (messageTemplate.Length == 0) { <>2__current = EmptyTextToken; <>1__state = 1; return true; } 5__2 = 0; goto IL_005e; case 1: <>1__state = -1; return false; case 2: <>1__state = -1; goto IL_009d; case 3: { <>1__state = -1; goto IL_00f2; } IL_009d: if (5__2 == messageTemplate.Length) { return false; } num2 = 5__2; messageTemplateToken = messageTemplateParser.ParsePropertyToken(5__2, messageTemplate, out 5__2); if (num2 < 5__2) { <>2__current = messageTemplateToken; <>1__state = 3; return true; } goto IL_00f2; IL_005e: num3 = 5__2; textToken = ParseTextToken(5__2, messageTemplate, out 5__2); if (5__2 > num3) { <>2__current = textToken; <>1__state = 2; return true; } goto IL_009d; IL_00f2: if (5__2 == messageTemplate.Length) { return false; } goto IL_005e; } } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { d__6 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__6(0) { <>4__this = <>4__this }; } d__.messageTemplate = <>3__messageTemplate; return d__; } [DebuggerHidden] System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable)this).GetEnumerator(); } } private static readonly bool DefaultAcceptDottedPropertyNames; private static readonly TextToken EmptyTextToken; private readonly bool _acceptDottedPropertyNames; public MessageTemplateParser() : this(DefaultAcceptDottedPropertyNames) { } internal MessageTemplateParser(bool acceptDottedPropertyNames) { _acceptDottedPropertyNames = acceptDottedPropertyNames; } public MessageTemplate Parse(string messageTemplate) { Guard.AgainstNull(messageTemplate, "messageTemplate"); return new MessageTemplate(messageTemplate, Tokenize(messageTemplate)); } [IteratorStateMachine(typeof(d__6))] private System.Collections.Generic.IEnumerable Tokenize(string messageTemplate) { if (messageTemplate.Length == 0) { yield return EmptyTextToken; yield break; } int nextIndex = 0; do { int num = nextIndex; TextToken textToken = ParseTextToken(nextIndex, messageTemplate, out nextIndex); if (nextIndex > num) { yield return textToken; } if (nextIndex == messageTemplate.Length) { break; } int num2 = nextIndex; MessageTemplateToken messageTemplateToken = ParsePropertyToken(nextIndex, messageTemplate, out nextIndex); if (num2 < nextIndex) { yield return messageTemplateToken; } } while (nextIndex != messageTemplate.Length); } private MessageTemplateToken ParsePropertyToken(int startAt, string messageTemplate, out int next) { int num = startAt; startAt++; startAt = messageTemplate.IndexOf('}', startAt); if (startAt == -1) { next = messageTemplate.Length; return new TextToken(messageTemplate.Substring(num)); } next = startAt + 1; string text = messageTemplate.Substring(num, next - num); string text2 = text.Substring(1, next - (num + 2)); if (text2.Length == 0) { return new TextToken(text); } if (!TrySplitTagContent(text2, out string propertyNameAndDestructuring, out string format, out string alignment)) { return new TextToken(text); } string text3 = propertyNameAndDestructuring; Destructuring destructuring = Destructuring.Default; if (text3.Length != 0 && TryGetDestructuringHint(text3[0], out destructuring)) { text3 = text3.Substring(1); } if (text3.Length == 0) { return new TextToken(text); } foreach (char c in text3) { if (!IsValidInPropertyName(c)) { return new TextToken(text); } } if (format != null) { for (int j = 0; j < format.Length; j++) { if (!IsValidInFormat(format[j])) { return new TextToken(text); } } } Alignment? alignment2 = null; if (alignment != null) { if (alignment[0] == '+') { return new TextToken(text); } int num2 = default(int); if (!int.TryParse(alignment, (NumberStyles)4, (IFormatProvider)(object)CultureInfo.InvariantCulture, ref num2)) { return new TextToken(text); } AlignmentDirection direction = ((alignment[0] != '-') ? AlignmentDirection.Right : AlignmentDirection.Left); alignment2 = new Alignment(direction, Math.Abs(num2)); } return new PropertyToken(text3, text, format, in alignment2, destructuring); } private static bool TrySplitTagContent(string tagContent, [NotNullWhen(true)] out string? propertyNameAndDestructuring, out string? format, out string? alignment) { int num = tagContent.IndexOf(':'); int num2 = tagContent.IndexOf(','); if (num == -1 && num2 == -1) { propertyNameAndDestructuring = tagContent; format = null; alignment = null; return true; } if (num2 == -1 || (num != -1 && num2 > num)) { propertyNameAndDestructuring = tagContent.Substring(0, num); format = ((num == tagContent.Length - 1) ? null : tagContent.Substring(num + 1)); alignment = null; return true; } propertyNameAndDestructuring = tagContent.Substring(0, num2); if (num == -1) { if (num2 == tagContent.Length - 1) { alignment = (format = null); return false; } format = null; alignment = tagContent.Substring(num2 + 1); return true; } if (num2 == num - 1) { alignment = (format = null); return false; } alignment = tagContent.Substring(num2 + 1, num - num2 - 1); format = ((num == tagContent.Length - 1) ? null : tagContent.Substring(num + 1)); return true; } private bool IsValidInPropertyName(char c) { if (!char.IsLetterOrDigit(c) && c != '_') { if (_acceptDottedPropertyNames) { return c == '.'; } return false; } return true; } private static bool TryGetDestructuringHint(char c, out Destructuring destructuring) { switch (c) { case '@': destructuring = Destructuring.Destructure; return true; case '$': destructuring = Destructuring.Stringify; return true; default: destructuring = Destructuring.Default; return false; } } private static bool IsValidInFormat(char c) { return c != '}'; } private static TextToken ParseTextToken(int startAt, string messageTemplate, out int next) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown int num = messageTemplate.IndexOfAny(new char[2] { '{', '}' }, startAt); if (num == -1) { next = messageTemplate.Length; return new TextToken(messageTemplate.Substring(startAt, messageTemplate.Length - startAt)); } char c = messageTemplate[num]; num++; StringBuilder val; if (c == '{') { if (num >= messageTemplate.Length || messageTemplate[num] != '{') { next = num - 1; if (next != startAt) { return new TextToken(messageTemplate.Substring(startAt, num - 1 - startAt)); } return EmptyTextToken; } val = new StringBuilder(messageTemplate, startAt, num - startAt, messageTemplate.Length - startAt); num++; } else { val = new StringBuilder(messageTemplate, startAt, num - startAt, messageTemplate.Length - startAt); if (num < messageTemplate.Length && messageTemplate[num] == '}') { num++; } } while (num < messageTemplate.Length) { c = messageTemplate[num]; num++; if (c == '{') { if (num >= messageTemplate.Length || messageTemplate[num] != '{') { next = num - 1; return new TextToken(((object)val).ToString()); } val.Append(c); num++; } else { val.Append(c); if (c == '}' && num < messageTemplate.Length && messageTemplate[num] == '}') { num++; } } } next = num; return new TextToken(((object)val).ToString()); } static MessageTemplateParser() { bool flag = default(bool); DefaultAcceptDottedPropertyNames = AppContext.TryGetSwitch("Serilog.Parsing.MessageTemplateParser.AcceptDottedPropertyNames", ref flag) && flag; EmptyTextToken = new TextToken(""); } } public abstract class MessageTemplateToken { public abstract int Length { get; } public abstract void Render(IReadOnlyDictionary properties, TextWriter output, IFormatProvider? formatProvider = null); } public sealed class PropertyToken : MessageTemplateToken { private readonly int? _position; public override int Length => RawText.Length; [field: CompilerGenerated] public string PropertyName { [CompilerGenerated] get; } [field: CompilerGenerated] public Destructuring Destructuring { [CompilerGenerated] get; } [field: CompilerGenerated] public string? Format { [CompilerGenerated] get; } [field: CompilerGenerated] public Alignment? Alignment { [CompilerGenerated] get; } public bool IsPositional => _position.HasValue; [field: CompilerGenerated] internal string RawText { [CompilerGenerated] get; } public PropertyToken(string propertyName, string rawText, string? format = null, in Alignment? alignment = null, Destructuring destructuring = Destructuring.Default) { PropertyName = Guard.AgainstNull(propertyName, "propertyName"); Format = format; Destructuring = destructuring; RawText = Guard.AgainstNull(rawText, "rawText"); Alignment = alignment; int num = default(int); if (int.TryParse(PropertyName, (NumberStyles)0, (IFormatProvider)(object)CultureInfo.InvariantCulture, ref num) && num >= 0) { _position = num; } } public override void Render(IReadOnlyDictionary properties, TextWriter output, IFormatProvider? formatProvider = null) { Guard.AgainstNull>(properties, "properties"); Guard.AgainstNull(output, "output"); MessageTemplateRenderer.RenderPropertyToken(this, properties, output, formatProvider, isLiteral: false, isJson: false); } public bool TryGetPositionalValue(out int position) { if (!_position.HasValue) { position = 0; return false; } position = _position.Value; return true; } public bool Equals(object? obj) { if (obj is PropertyToken propertyToken && propertyToken.Destructuring == Destructuring && propertyToken.Format == Format && propertyToken.PropertyName == PropertyName) { return propertyToken.RawText == RawText; } return false; } public int GetHashCode() { return ((object)PropertyName).GetHashCode(); } public string ToString() { return RawText; } } public sealed class TextToken : MessageTemplateToken { public override int Length => Text.Length; [field: CompilerGenerated] public string Text { [CompilerGenerated] get; } public TextToken(string text) { Text = Guard.AgainstNull(text, "text"); } public override void Render(IReadOnlyDictionary properties, TextWriter output, IFormatProvider? formatProvider = null) { Guard.AgainstNull(output, "output"); MessageTemplateRenderer.RenderTextToken(this, output); } public bool Equals(object? obj) { if (obj is TextToken textToken) { return textToken.Text == Text; } return false; } public int GetHashCode() { return ((object)Text).GetHashCode(); } public string ToString() { return Text; } } } namespace Serilog.Formatting { public interface ITextFormatter { void Format(LogEvent logEvent, TextWriter output); } } namespace Serilog.Formatting.Json { public sealed class JsonFormatter : ITextFormatter { private readonly string _closingDelimiter; private readonly bool _renderMessage; private readonly IFormatProvider? _formatProvider; private readonly JsonValueFormatter _jsonValueFormatter = new JsonValueFormatter(); public JsonFormatter(string? closingDelimiter = null, bool renderMessage = false, IFormatProvider? formatProvider = null) { _closingDelimiter = closingDelimiter ?? Environment.NewLine; _renderMessage = renderMessage; _formatProvider = formatProvider; } public void Format(LogEvent logEvent, TextWriter output) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) Guard.AgainstNull(logEvent, "logEvent"); Guard.AgainstNull(output, "output"); output.Write("{\"Timestamp\":\""); DateTimeOffset timestamp = logEvent.Timestamp; output.Write(((DateTimeOffset)(ref timestamp)).ToString("O")); output.Write("\",\"Level\":\""); output.Write((object)logEvent.Level); output.Write("\",\"MessageTemplate\":"); JsonValueFormatter.WriteQuotedJsonString(logEvent.MessageTemplate.Text, output); if (_renderMessage) { output.Write(",\"RenderedMessage\":"); JsonValueFormatter.WriteQuotedJsonString(logEvent.MessageTemplate.Render(logEvent.Properties), output); } if (logEvent.TraceId.HasValue) { output.Write(",\"TraceId\":"); JsonValueFormatter.WriteQuotedJsonString(((object)logEvent.TraceId).ToString(), output); } if (logEvent.SpanId.HasValue) { output.Write(",\"SpanId\":"); JsonValueFormatter.WriteQuotedJsonString(((object)logEvent.SpanId).ToString(), output); } if (logEvent.Exception != null) { output.Write(",\"Exception\":"); JsonValueFormatter.WriteQuotedJsonString(((object)logEvent.Exception).ToString(), output); } if (((System.Collections.Generic.IReadOnlyCollection>)logEvent.Properties).Count != 0) { output.Write(",\"Properties\":{"); char? c = null; System.Collections.Generic.IEnumerator> enumerator = ((System.Collections.Generic.IEnumerable>)logEvent.Properties).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { KeyValuePair current = enumerator.Current; if (c.HasValue) { output.Write(c.Value); } else { c = ','; } JsonValueFormatter.WriteQuotedJsonString(current.Key, output); output.Write(':'); _jsonValueFormatter.Format(current.Value, output); } } finally { ((System.IDisposable)enumerator)?.Dispose(); } output.Write('}'); } IGrouping[] array = Enumerable.ToArray>(Enumerable.GroupBy(Enumerable.Where(Enumerable.OfType((System.Collections.IEnumerable)(object)logEvent.MessageTemplate.TokenArray), (Func)((PropertyToken pt) => pt.Format != null)), (Func)((PropertyToken pt) => pt.PropertyName))); if (array.Length != 0) { output.Write(",\"Renderings\":{"); WriteRenderingsValues(array, logEvent.Properties, output); output.Write('}'); } output.Write('}'); output.Write(_closingDelimiter); } private void WriteRenderingsValues(System.Collections.Generic.IEnumerable> tokensWithFormat, IReadOnlyDictionary properties, TextWriter output) { char? c = null; System.Collections.Generic.IEnumerator> enumerator = tokensWithFormat.GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { IGrouping current = enumerator.Current; if (c.HasValue) { output.Write(c.Value); } else { c = ','; } output.Write('"'); output.Write(current.Key); output.Write("\":["); char? c2 = null; System.Collections.Generic.IEnumerator enumerator2 = ((System.Collections.Generic.IEnumerable)current).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator2).MoveNext()) { PropertyToken current2 = enumerator2.Current; if (c2.HasValue) { output.Write(c2.Value); } c2 = ','; output.Write('{'); char? precedingDelimiter2 = null; WriteNameValuePair("Format", current2.Format, ref precedingDelimiter2, output); StringWriter orCreate = ReusableStringWriter.GetOrCreate(); try { MessageTemplateRenderer.RenderPropertyToken(current2, properties, (TextWriter)(object)orCreate, _formatProvider, isLiteral: true, isJson: false); WriteNameValuePair("Rendering", ((object)orCreate).ToString(), ref precedingDelimiter2, output); output.Write('}'); } finally { ((System.IDisposable)orCreate)?.Dispose(); } } } finally { ((System.IDisposable)enumerator2)?.Dispose(); } output.Write(']'); } } finally { ((System.IDisposable)enumerator)?.Dispose(); } [CompilerGenerated] static void WriteNameValuePair(string name, string value, ref char? precedingDelimiter, TextWriter output) { if (precedingDelimiter.HasValue) { output.Write(precedingDelimiter.Value); } JsonValueFormatter.WriteQuotedJsonString(name, output); output.Write(':'); JsonValueFormatter.WriteQuotedJsonString(value, output); precedingDelimiter = ','; } } } public class JsonValueFormatter : LogEventPropertyValueVisitor { private readonly string? _typeTagName; private const string DefaultTypeTagName = "_typeTag"; public JsonValueFormatter(string? typeTagName = "_typeTag") { _typeTagName = typeTagName; } public void Format(LogEventPropertyValue value, TextWriter output) { Visit(output, value); } protected override bool VisitScalarValue(TextWriter state, ScalarValue scalar) { Guard.AgainstNull(scalar, "scalar"); FormatLiteralValue(scalar.Value, state); return false; } protected override bool VisitSequenceValue(TextWriter state, SequenceValue sequence) { Guard.AgainstNull(sequence, "sequence"); state.Write('['); char? c = null; for (int i = 0; i < ((System.Collections.Generic.IReadOnlyCollection)sequence.Elements).Count; i++) { if (c.HasValue) { state.Write(c.Value); } c = ','; Visit(state, sequence.Elements[i]); } state.Write(']'); return false; } protected override bool VisitStructureValue(TextWriter state, StructureValue structure) { state.Write('{'); char? c = null; for (int i = 0; i < ((System.Collections.Generic.IReadOnlyCollection)structure.Properties).Count; i++) { if (c.HasValue) { state.Write(c.Value); } c = ','; LogEventProperty logEventProperty = structure.Properties[i]; WriteQuotedJsonString(logEventProperty.Name, state); state.Write(':'); Visit(state, logEventProperty.Value); } if (_typeTagName != null && structure.TypeTag != null) { state.Write((object)c); WriteQuotedJsonString(_typeTagName, state); state.Write(':'); WriteQuotedJsonString(structure.TypeTag, state); } state.Write('}'); return false; } protected override bool VisitDictionaryValue(TextWriter state, DictionaryValue dictionary) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) state.Write('{'); char? c = null; System.Collections.Generic.IEnumerator> enumerator = ((System.Collections.Generic.IEnumerable>)dictionary.Elements).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { KeyValuePair current = enumerator.Current; if (c.HasValue) { state.Write(c.Value); } c = ','; WriteQuotedJsonString((current.Key.Value ?? "null").ToString(), state); state.Write(':'); Visit(state, current.Value); } } finally { ((System.IDisposable)enumerator)?.Dispose(); } state.Write('}'); return false; } protected virtual void FormatLiteralValue(object? value, TextWriter output) { //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) if (value == null) { FormatNullValue(output); return; } if (value is string str) { FormatStringValue(str, output); return; } if (value is System.ValueType) { if (value is int value2) { FormatExactNumericValue(value2, output); return; } if (value is uint value3) { FormatExactNumericValue(value3, output); return; } if (value is long value4) { FormatExactNumericValue(value4, output); return; } if (value is ulong value5) { FormatExactNumericValue(value5, output); return; } if (value is decimal value6) { FormatExactNumericValue(value6, output); return; } if (value is byte value7) { FormatExactNumericValue(value7, output); return; } if (value is sbyte value8) { FormatExactNumericValue(value8, output); return; } if (value is short value9) { FormatExactNumericValue(value9, output); return; } if (value is ushort value10) { FormatExactNumericValue(value10, output); return; } if (value is double value11) { FormatDoubleValue(value11, output); return; } if (value is float value12) { FormatFloatValue(value12, output); return; } if (value is bool value13) { FormatBooleanValue(value13, output); return; } if (value is char) { FormatStringValue(value.ToString(), output); return; } if (value is System.DateTime value14) { FormatDateTimeValue(value14, output); return; } if (value is DateTimeOffset value15) { FormatDateTimeOffsetValue(value15, output); return; } if (value is TimeSpan value16) { FormatTimeSpanValue(value16, output); return; } if (value is DateOnly value17) { FormatDateOnlyValue(value17, output); return; } if (value is TimeOnly value18) { FormatTimeOnlyValue(value18, output); return; } } FormatLiteralObjectValue(value, output); } private static void FormatBooleanValue(bool value, TextWriter output) { output.Write(value ? "true" : "false"); } private static void FormatFloatValue(float value, TextWriter output) { if (float.IsNaN(value) || float.IsInfinity(value)) { FormatStringValue(value.ToString((IFormatProvider)(object)CultureInfo.InvariantCulture), output); return; } System.Span span = stackalloc char[64]; int num = default(int); if (value.TryFormat(span, ref num, string.op_Implicit("R"), (IFormatProvider)(object)CultureInfo.InvariantCulture)) { output.Write(System.Span.op_Implicit(span.Slice(0, num))); } else { output.Write(value.ToString("R", (IFormatProvider)(object)CultureInfo.InvariantCulture)); } } private static void FormatDoubleValue(double value, TextWriter output) { if (double.IsNaN(value) || double.IsInfinity(value)) { FormatStringValue(value.ToString((IFormatProvider)(object)CultureInfo.InvariantCulture), output); return; } System.Span span = stackalloc char[64]; int num = default(int); if (value.TryFormat(span, ref num, string.op_Implicit("R"), (IFormatProvider)(object)CultureInfo.InvariantCulture)) { output.Write(System.Span.op_Implicit(span.Slice(0, num))); } else { output.Write(value.ToString("R", (IFormatProvider)(object)CultureInfo.InvariantCulture)); } } private static void FormatExactNumericValue(int value, TextWriter output) { System.Span span = stackalloc char[64]; System.Span span2 = span; IFormatProvider invariantCulture = (IFormatProvider)(object)CultureInfo.InvariantCulture; int num = default(int); if (value.TryFormat(span2, ref num, default(System.ReadOnlySpan), invariantCulture)) { output.Write(System.Span.op_Implicit(span.Slice(0, num))); } else { output.Write(value.ToString((string)null, (IFormatProvider)(object)CultureInfo.InvariantCulture)); } } private static void FormatExactNumericValue(uint value, TextWriter output) { System.Span span = stackalloc char[64]; System.Span span2 = span; IFormatProvider invariantCulture = (IFormatProvider)(object)CultureInfo.InvariantCulture; int num = default(int); if (value.TryFormat(span2, ref num, default(System.ReadOnlySpan), invariantCulture)) { output.Write(System.Span.op_Implicit(span.Slice(0, num))); } else { output.Write(value.ToString((string)null, (IFormatProvider)(object)CultureInfo.InvariantCulture)); } } private static void FormatExactNumericValue(long value, TextWriter output) { System.Span span = stackalloc char[64]; System.Span span2 = span; IFormatProvider invariantCulture = (IFormatProvider)(object)CultureInfo.InvariantCulture; int num = default(int); if (value.TryFormat(span2, ref num, default(System.ReadOnlySpan), invariantCulture)) { output.Write(System.Span.op_Implicit(span.Slice(0, num))); } else { output.Write(value.ToString((string)null, (IFormatProvider)(object)CultureInfo.InvariantCulture)); } } private static void FormatExactNumericValue(ulong value, TextWriter output) { System.Span span = stackalloc char[64]; System.Span span2 = span; IFormatProvider invariantCulture = (IFormatProvider)(object)CultureInfo.InvariantCulture; int num = default(int); if (value.TryFormat(span2, ref num, default(System.ReadOnlySpan), invariantCulture)) { output.Write(System.Span.op_Implicit(span.Slice(0, num))); } else { output.Write(value.ToString((string)null, (IFormatProvider)(object)CultureInfo.InvariantCulture)); } } private static void FormatExactNumericValue(decimal value, TextWriter output) { System.Span span = stackalloc char[64]; System.Span span2 = span; IFormatProvider invariantCulture = (IFormatProvider)(object)CultureInfo.InvariantCulture; int num = default(int); if (value.TryFormat(span2, ref num, default(System.ReadOnlySpan), invariantCulture)) { output.Write(System.Span.op_Implicit(span.Slice(0, num))); } else { output.Write(value.ToString((string)null, (IFormatProvider)(object)CultureInfo.InvariantCulture)); } } private static void FormatExactNumericValue(byte value, TextWriter output) { System.Span span = stackalloc char[64]; System.Span span2 = span; IFormatProvider invariantCulture = (IFormatProvider)(object)CultureInfo.InvariantCulture; int num = default(int); if (value.TryFormat(span2, ref num, default(System.ReadOnlySpan), invariantCulture)) { output.Write(System.Span.op_Implicit(span.Slice(0, num))); } else { output.Write(value.ToString((string)null, (IFormatProvider)(object)CultureInfo.InvariantCulture)); } } private static void FormatExactNumericValue(sbyte value, TextWriter output) { System.Span span = stackalloc char[64]; System.Span span2 = span; IFormatProvider invariantCulture = (IFormatProvider)(object)CultureInfo.InvariantCulture; int num = default(int); if (value.TryFormat(span2, ref num, default(System.ReadOnlySpan), invariantCulture)) { output.Write(System.Span.op_Implicit(span.Slice(0, num))); } else { output.Write(value.ToString((string)null, (IFormatProvider)(object)CultureInfo.InvariantCulture)); } } private static void FormatExactNumericValue(short value, TextWriter output) { System.Span span = stackalloc char[64]; System.Span span2 = span; IFormatProvider invariantCulture = (IFormatProvider)(object)CultureInfo.InvariantCulture; int num = default(int); if (value.TryFormat(span2, ref num, default(System.ReadOnlySpan), invariantCulture)) { output.Write(System.Span.op_Implicit(span.Slice(0, num))); } else { output.Write(value.ToString((string)null, (IFormatProvider)(object)CultureInfo.InvariantCulture)); } } private static void FormatExactNumericValue(ushort value, TextWriter output) { System.Span span = stackalloc char[64]; System.Span span2 = span; IFormatProvider invariantCulture = (IFormatProvider)(object)CultureInfo.InvariantCulture; int num = default(int); if (value.TryFormat(span2, ref num, default(System.ReadOnlySpan), invariantCulture)) { output.Write(System.Span.op_Implicit(span.Slice(0, num))); } else { output.Write(value.ToString((string)null, (IFormatProvider)(object)CultureInfo.InvariantCulture)); } } private static void FormatDateTimeValue(System.DateTime value, TextWriter output) { output.Write('"'); System.Span span = stackalloc char[64]; int num = default(int); if (value.TryFormat(span, ref num, string.op_Implicit("O"), (IFormatProvider)null)) { output.Write(System.Span.op_Implicit(span.Slice(0, num))); } else { output.Write(value.ToString("O", (IFormatProvider)(object)CultureInfo.InvariantCulture)); } output.Write('"'); } private static void FormatDateTimeOffsetValue(DateTimeOffset value, TextWriter output) { output.Write('"'); System.Span span = stackalloc char[64]; int num = default(int); if (((DateTimeOffset)(ref value)).TryFormat(span, ref num, string.op_Implicit("O"), (IFormatProvider)null)) { output.Write(System.Span.op_Implicit(span.Slice(0, num))); } else { output.Write(((DateTimeOffset)(ref value)).ToString("O", (IFormatProvider)(object)CultureInfo.InvariantCulture)); } output.Write('"'); } private static void FormatTimeSpanValue(TimeSpan value, TextWriter output) { output.Write('"'); System.Span span = stackalloc char[64]; int num = default(int); if (((TimeSpan)(ref value)).TryFormat(span, ref num, default(System.ReadOnlySpan), (IFormatProvider)null)) { output.Write(System.Span.op_Implicit(span.Slice(0, num))); } else { output.Write(((object)(TimeSpan)(ref value)).ToString()); } output.Write('"'); } private static void FormatDateOnlyValue(DateOnly value, TextWriter output) { output.Write('"'); System.Span span = stackalloc char[10]; int num = default(int); if (((DateOnly)(ref value)).TryFormat(span, ref num, string.op_Implicit("yyyy-MM-dd"), (IFormatProvider)null)) { output.Write(System.Span.op_Implicit(span.Slice(0, num))); } else { output.Write(((DateOnly)(ref value)).ToString("yyyy-MM-dd")); } output.Write('"'); } private static void FormatTimeOnlyValue(TimeOnly value, TextWriter output) { output.Write('"'); System.Span span = stackalloc char[16]; int num = default(int); if (((TimeOnly)(ref value)).TryFormat(span, ref num, string.op_Implicit("O"), (IFormatProvider)null)) { output.Write(System.Span.op_Implicit(span.Slice(0, num))); } else { output.Write(((TimeOnly)(ref value)).ToString("O")); } output.Write('"'); } private static void FormatLiteralObjectValue(object value, TextWriter output) { Guard.AgainstNull(value, "value"); FormatStringValue(value.ToString() ?? "", output); } private static void FormatStringValue(string str, TextWriter output) { WriteQuotedJsonString(str, output); } private static void FormatNullValue(TextWriter output) { output.Write("null"); } public static void WriteQuotedJsonString(string str, TextWriter output) { output.Write('"'); int num = 0; bool flag = false; for (int i = 0; i < str.Length; i++) { char c = str[i]; if ((c < ' ' || c == '"' || c == '\\') ? true : false) { flag = true; output.Write(MemoryExtensions.AsSpan(str).Slice(num, i - num)); num = i + 1; switch (c) { case '"': output.Write("\\\""); continue; case '\\': output.Write("\\\\"); continue; case '\n': output.Write("\\n"); continue; case '\r': output.Write("\\r"); continue; case '\f': output.Write("\\f"); continue; case '\t': output.Write("\\t"); continue; } output.Write("\\u"); int num2 = c; output.Write(num2.ToString("X4")); } } if (flag) { if (num != str.Length) { output.Write(MemoryExtensions.AsSpan(str).Slice(num)); } } else { output.Write(str); } output.Write('"'); } } } namespace Serilog.Formatting.Display { internal static class LevelOutputFormat { private static readonly string[][] _titleCaseLevelMap = new string[6][] { new string[7] { "V", "Vb", "Vrb", "Verb", "Verbo", "Verbos", "Verbose" }, new string[5] { "D", "De", "Dbg", "Dbug", "Debug" }, new string[11] { "I", "In", "Inf", "Info", "Infor", "Inform", "Informa", "Informat", "Informati", "Informatio", "Information" }, new string[7] { "W", "Wn", "Wrn", "Warn", "Warni", "Warnin", "Warning" }, new string[5] { "E", "Er", "Err", "Eror", "Error" }, new string[5] { "F", "Fa", "Ftl", "Fatl", "Fatal" } }; private static readonly string[][] _lowerCaseLevelMap = new string[6][] { new string[7] { "v", "vb", "vrb", "verb", "verbo", "verbos", "verbose" }, new string[5] { "d", "de", "dbg", "dbug", "debug" }, new string[11] { "i", "in", "inf", "info", "infor", "inform", "informa", "informat", "informati", "informatio", "information" }, new string[7] { "w", "wn", "wrn", "warn", "warni", "warnin", "warning" }, new string[5] { "e", "er", "err", "eror", "error" }, new string[5] { "f", "fa", "ftl", "fatl", "fatal" } }; private static readonly string[][] _upperCaseLevelMap = new string[6][] { new string[7] { "V", "VB", "VRB", "VERB", "VERBO", "VERBOS", "VERBOSE" }, new string[5] { "D", "DE", "DBG", "DBUG", "DEBUG" }, new string[11] { "I", "IN", "INF", "INFO", "INFOR", "INFORM", "INFORMA", "INFORMAT", "INFORMATI", "INFORMATIO", "INFORMATION" }, new string[7] { "W", "WN", "WRN", "WARN", "WARNI", "WARNIN", "WARNING" }, new string[5] { "E", "ER", "ERR", "EROR", "ERROR" }, new string[5] { "F", "FA", "FTL", "FATL", "FATAL" } }; public static string GetLevelMoniker(LogEventLevel value, string? format = null) { if ((value < LogEventLevel.Verbose || value > LogEventLevel.Fatal) ? true : false) { return Casing.Format(((object)value).ToString(), format); } if (format == null || (format.Length != 2 && format.Length != 3)) { return Casing.Format(GetLevelMoniker(_titleCaseLevelMap, value), format); } int num = format[1] - 48; if (format.Length == 3) { num *= 10; num += format[2] - 48; } if (num < 1) { return string.Empty; } return format[0] switch { 'w' => GetLevelMoniker(_lowerCaseLevelMap, value, num), 'u' => GetLevelMoniker(_upperCaseLevelMap, value, num), 't' => GetLevelMoniker(_titleCaseLevelMap, value, num), _ => Casing.Format(GetLevelMoniker(_titleCaseLevelMap, value), format), }; } private static string GetLevelMoniker(string[][] caseLevelMap, LogEventLevel level, int width) { string[] array = caseLevelMap[(int)level]; return array[Math.Min(width, array.Length) - 1]; } private static string GetLevelMoniker(string[][] caseLevelMap, LogEventLevel level) { string[] obj = caseLevelMap[(int)level]; return obj[obj.Length - 1]; } } public class MessageTemplateTextFormatter : ITextFormatter { private readonly IFormatProvider? _formatProvider; private readonly MessageTemplate _outputTemplate; public MessageTemplateTextFormatter(string outputTemplate, IFormatProvider? formatProvider = null) { Guard.AgainstNull(outputTemplate, "outputTemplate"); _outputTemplate = new MessageTemplateParser().Parse(outputTemplate); _formatProvider = formatProvider; } public void Format(LogEvent logEvent, TextWriter output) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) Guard.AgainstNull(logEvent, "logEvent"); Guard.AgainstNull(output, "output"); MessageTemplateToken[] tokenArray = _outputTemplate.TokenArray; LogEventPropertyValue logEventPropertyValue = default(LogEventPropertyValue); foreach (MessageTemplateToken messageTemplateToken in tokenArray) { if (messageTemplateToken is TextToken tt) { MessageTemplateRenderer.RenderTextToken(tt, output); continue; } PropertyToken propertyToken = (PropertyToken)messageTemplateToken; if (propertyToken.PropertyName == "Level") { string levelMoniker = LevelOutputFormat.GetLevelMoniker(logEvent.Level, propertyToken.Format); Alignment? alignment = propertyToken.Alignment; Padding.Apply(output, levelMoniker, in alignment); continue; } if (propertyToken.PropertyName == "TraceId") { ActivityTraceId? traceId = logEvent.TraceId; object obj; if (!traceId.HasValue) { obj = null; } else { ActivityTraceId valueOrDefault = traceId.GetValueOrDefault(); obj = ((object)(ActivityTraceId)(ref valueOrDefault)).ToString(); } if (obj == null) { obj = ""; } Alignment? alignment = propertyToken.Alignment; Padding.Apply(output, (string)obj, in alignment); continue; } if (propertyToken.PropertyName == "SpanId") { ActivitySpanId? spanId = logEvent.SpanId; object obj2; if (!spanId.HasValue) { obj2 = null; } else { ActivitySpanId valueOrDefault2 = spanId.GetValueOrDefault(); obj2 = ((object)(ActivitySpanId)(ref valueOrDefault2)).ToString(); } if (obj2 == null) { obj2 = ""; } Alignment? alignment = propertyToken.Alignment; Padding.Apply(output, (string)obj2, in alignment); continue; } if (propertyToken.PropertyName == "NewLine") { string newLine = Environment.NewLine; Alignment? alignment = propertyToken.Alignment; Padding.Apply(output, newLine, in alignment); continue; } if (propertyToken.PropertyName == "Exception") { string value = ((logEvent.Exception == null) ? "" : (((object)logEvent.Exception)?.ToString() + Environment.NewLine)); Alignment? alignment = propertyToken.Alignment; Padding.Apply(output, value, in alignment); continue; } TextWriter val = (TextWriter)(propertyToken.Alignment.HasValue ? ((object)ReusableStringWriter.GetOrCreate()) : ((object)output)); if (propertyToken.PropertyName == "Message") { MessageTemplateRenderer.Render(logEvent.MessageTemplate, logEvent.Properties, val, propertyToken.Format, _formatProvider); } else if (propertyToken.PropertyName == "Timestamp") { ScalarValue.Render(logEvent.Timestamp, val, propertyToken.Format, _formatProvider); } else if (propertyToken.PropertyName == "UtcTimestamp") { DateTimeOffset timestamp = logEvent.Timestamp; ScalarValue.Render(((DateTimeOffset)(ref timestamp)).UtcDateTime, val, propertyToken.Format, _formatProvider); } else if (propertyToken.PropertyName == "Properties") { PropertiesOutputFormat.Render(logEvent.MessageTemplate, logEvent.Properties, _outputTemplate, val, propertyToken.Format, _formatProvider); } else { if (!logEvent.Properties.TryGetValue(propertyToken.PropertyName, ref logEventPropertyValue)) { continue; } if ((logEventPropertyValue as ScalarValue)?.Value is string value2) { string text = Casing.Format(value2, propertyToken.Format); val.Write(text); } else { logEventPropertyValue.Render(val, propertyToken.Format, _formatProvider); } } if (propertyToken.Alignment.HasValue) { StringBuilder stringBuilder = ((StringWriter)val).GetStringBuilder(); Alignment? alignment = propertyToken.Alignment; Padding.Apply(output, stringBuilder, in alignment); val.Dispose(); } } } } public static class OutputProperties { public const string MessagePropertyName = "Message"; public const string TimestampPropertyName = "Timestamp"; public const string UtcTimestampPropertyName = "UtcTimestamp"; public const string LevelPropertyName = "Level"; public const string TraceIdPropertyName = "TraceId"; public const string SpanIdPropertyName = "SpanId"; public const string NewLinePropertyName = "NewLine"; public const string ExceptionPropertyName = "Exception"; public const string PropertiesPropertyName = "Properties"; } internal static class PropertiesOutputFormat { private static readonly JsonValueFormatter JsonValueFormatter = new JsonValueFormatter("$type"); public static void Render(MessageTemplate template, IReadOnlyDictionary properties, MessageTemplate outputTemplate, TextWriter output, string? format, IFormatProvider? formatProvider = null) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) MessageTemplate template2 = template; MessageTemplate outputTemplate2 = outputTemplate; if (format != null && format.Contains("j")) { StructureValue value = new StructureValue(Enumerable.Select, LogEventProperty>(Enumerable.Where>((System.Collections.Generic.IEnumerable>)properties, (Func, bool>)((KeyValuePair kvp) => !TemplateContainsPropertyName(template2, kvp.Key) && !TemplateContainsPropertyName(outputTemplate2, kvp.Key))), (Func, LogEventProperty>)((KeyValuePair kvp) => new LogEventProperty(kvp.Key, kvp.Value)))); JsonValueFormatter.Format(value, output); return; } output.Write("{ "); string text = ""; System.Collections.Generic.IEnumerator> enumerator = ((System.Collections.Generic.IEnumerable>)properties).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { KeyValuePair current = enumerator.Current; if (!TemplateContainsPropertyName(template2, current.Key) && !TemplateContainsPropertyName(outputTemplate2, current.Key)) { output.Write(text); text = ", "; output.Write(current.Key); output.Write(": "); current.Value.Render(output, null, formatProvider); } } } finally { ((System.IDisposable)enumerator)?.Dispose(); } output.Write(" }"); } private static bool TemplateContainsPropertyName(MessageTemplate template, string propertyName) { if (template.PositionalProperties != null) { for (int i = 0; i < template.PositionalProperties.Length; i++) { if (template.PositionalProperties[i].PropertyName == propertyName) { return true; } } return false; } if (template.NamedProperties != null) { for (int j = 0; j < template.NamedProperties.Length; j++) { if (template.NamedProperties[j].PropertyName == propertyName) { return true; } } } return false; } } } namespace Serilog.Filters { public static class Matching { public static Func FromSource() { return WithProperty("SourceContext", typeof(TSource).FullName); } public static Func FromSource(string source) { string source2 = source; Guard.AgainstNull(source2, "source"); return WithProperty("SourceContext", (string s) => s != null && MemoryExtensions.StartsWith(MemoryExtensions.AsSpan(s), string.op_Implicit(source2)) && (s.Length == source2.Length || s[source2.Length] == '.')); } public static Func WithProperty(string propertyName) { string propertyName2 = propertyName; Guard.AgainstNull(propertyName2, "propertyName"); return (LogEvent e) => e.Properties.ContainsKey(propertyName2); } public static Func WithProperty(string propertyName, object scalarValue) { string propertyName2 = propertyName; Guard.AgainstNull(propertyName2, "propertyName"); ScalarValue scalar = new ScalarValue(scalarValue); LogEventPropertyValue logEventPropertyValue = default(LogEventPropertyValue); return (LogEvent e) => e.Properties.TryGetValue(propertyName2, ref logEventPropertyValue) && ((object)scalar).Equals((object)logEventPropertyValue); } public static Func WithProperty(string propertyName, Func predicate) { string propertyName2 = propertyName; Func predicate2 = predicate; Guard.AgainstNull(propertyName2, "propertyName"); Guard.AgainstNull>(predicate2, "predicate"); return delegate(LogEvent e) { LogEventPropertyValue logEventPropertyValue = default(LogEventPropertyValue); if (!e.Properties.TryGetValue(propertyName2, ref logEventPropertyValue)) { return false; } return logEventPropertyValue is ScalarValue scalarValue && scalarValue.Value is TScalar val && predicate2.Invoke(val); }; } } } namespace Serilog.Events { public class DictionaryValue : LogEventPropertyValue { [field: CompilerGenerated] public IReadOnlyDictionary Elements { [CompilerGenerated] get; } public DictionaryValue(System.Collections.Generic.IEnumerable> elements) { Guard.AgainstNull(elements, "elements"); Elements = (IReadOnlyDictionary)(object)Enumerable.ToDictionary, ScalarValue, LogEventPropertyValue>(elements, (Func, ScalarValue>)((KeyValuePair kvp) => kvp.Key), (Func, LogEventPropertyValue>)((KeyValuePair kvp) => kvp.Value)); } public override void Render(TextWriter output, string? format = null, IFormatProvider? formatProvider = null) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) Guard.AgainstNull(output, "output"); output.Write('['); string text = "("; System.Collections.Generic.IEnumerator> enumerator = ((System.Collections.Generic.IEnumerable>)Elements).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { KeyValuePair current = enumerator.Current; output.Write(text); text = ", ("; current.Key.Render(output, null, formatProvider); output.Write(": "); current.Value.Render(output, null, formatProvider); output.Write(')'); } } finally { ((System.IDisposable)enumerator)?.Dispose(); } output.Write(']'); } } internal readonly struct EventProperty { public static EventProperty None; [field: CompilerGenerated] public string Name { [CompilerGenerated] get; } [field: CompilerGenerated] public LogEventPropertyValue Value { [CompilerGenerated] get; } public EventProperty(string name, LogEventPropertyValue value) { Guard.AgainstNull(value, "value"); LogEventProperty.EnsureValidName(name); Name = name; Value = value; } public void Deconstruct(out string name, out LogEventPropertyValue value) { name = Name; value = Value; } public bool Equals(object? obj) { if (obj is EventProperty other) { return Equals(other); } return false; } public bool Equals(EventProperty other) { if (string.Equals(Name, other.Name)) { return object.Equals((object)Value, (object)other.Value); } return false; } public int GetHashCode() { return (((Name != null) ? ((object)Name).GetHashCode() : 0) * 397) ^ ((Value != null) ? ((object)Value).GetHashCode() : 0); } } public static class LevelAlias { public const LogEventLevel Minimum = LogEventLevel.Verbose; public const LogEventLevel Maximum = LogEventLevel.Fatal; public const LogEventLevel Off = (LogEventLevel)6; } public class LogEvent { private readonly Dictionary _properties; private ActivityTraceId _traceId; private ActivitySpanId _spanId; [field: CompilerGenerated] public DateTimeOffset Timestamp { [CompilerGenerated] get; } [field: CompilerGenerated] public LogEventLevel Level { [CompilerGenerated] get; } [CLSCompliant(false)] public ActivityTraceId? TraceId { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!(_traceId == default(ActivityTraceId))) { return _traceId; } return null; } } [CLSCompliant(false)] public ActivitySpanId? SpanId { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!(_spanId == default(ActivitySpanId))) { return _spanId; } return null; } } [field: CompilerGenerated] public MessageTemplate MessageTemplate { [CompilerGenerated] get; } public IReadOnlyDictionary Properties => (IReadOnlyDictionary)(object)_properties; [field: CompilerGenerated] public System.Exception? Exception { [CompilerGenerated] get; } private LogEvent(DateTimeOffset timestamp, LogEventLevel level, System.Exception? exception, MessageTemplate messageTemplate, Dictionary properties, ActivityTraceId traceId, ActivitySpanId spanId) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Timestamp = timestamp; Level = level; Exception = exception; _traceId = traceId; _spanId = spanId; MessageTemplate = Guard.AgainstNull(messageTemplate, "messageTemplate"); _properties = Guard.AgainstNull>(properties, "properties"); } public LogEvent(DateTimeOffset timestamp, LogEventLevel level, System.Exception? exception, MessageTemplate messageTemplate, System.Collections.Generic.IEnumerable properties) : this(timestamp, level, exception, messageTemplate, properties, default(ActivityTraceId), default(ActivitySpanId)) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) [CLSCompliant(false)] public LogEvent(DateTimeOffset timestamp, LogEventLevel level, System.Exception? exception, MessageTemplate messageTemplate, System.Collections.Generic.IEnumerable properties, ActivityTraceId traceId, ActivitySpanId spanId) : this(timestamp, level, exception, messageTemplate, new Dictionary(), traceId, spanId) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Guard.AgainstNull(properties, "properties"); System.Collections.Generic.IEnumerator enumerator = properties.GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { LogEventProperty current = enumerator.Current; AddOrUpdateProperty(current); } } finally { ((System.IDisposable)enumerator)?.Dispose(); } } internal LogEvent(DateTimeOffset timestamp, LogEventLevel level, System.Exception? exception, MessageTemplate messageTemplate, EventProperty[] properties, ActivityTraceId traceId, ActivitySpanId spanId) : this(timestamp, level, exception, messageTemplate, new Dictionary(Guard.AgainstNull(properties, "properties").Length), traceId, spanId) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < properties.Length; i++) { _properties[properties[i].Name] = properties[i].Value; } } public void RenderMessage(TextWriter output, IFormatProvider? formatProvider = null) { MessageTemplate.Render(Properties, output, formatProvider); } public string RenderMessage(IFormatProvider? formatProvider = null) { return MessageTemplate.Render(Properties, formatProvider); } public void AddOrUpdateProperty(LogEventProperty property) { Guard.AgainstNull(property, "property"); _properties[property.Name] = property.Value; } internal void AddOrUpdateProperty(in EventProperty property) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (property.Equals(EventProperty.None)) { throw new ArgumentNullException("property"); } _properties[property.Name] = property.Value; } public void AddPropertyIfAbsent(LogEventProperty property) { Guard.AgainstNull(property, "property"); _properties.TryAdd(property.Name, property.Value); } internal void AddPropertyIfAbsent(in EventProperty property) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (property.Equals(EventProperty.None)) { throw new ArgumentNullException("property"); } _properties.TryAdd(property.Name, property.Value); } internal void AddPropertyIfAbsent(ILogEventPropertyFactory factory, string name, object? value, bool destructureObjects = false) { if (!_properties.ContainsKey(name)) { _properties.Add(name, (factory is ILogEventPropertyValueFactory logEventPropertyValueFactory) ? logEventPropertyValueFactory.CreatePropertyValue(value, destructureObjects) : factory.CreateProperty(name, value, destructureObjects).Value); } } public void RemovePropertyIfPresent(string propertyName) { _properties.Remove(propertyName); } [CLSCompliant(false)] public static LogEvent UnstableAssembleFromParts(DateTimeOffset timestamp, LogEventLevel level, System.Exception? exception, MessageTemplate messageTemplate, Dictionary properties, ActivityTraceId traceId, ActivitySpanId spanId) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return new LogEvent(timestamp, level, exception, messageTemplate, properties, traceId, spanId); } internal LogEvent Copy() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) Dictionary properties = new Dictionary((IDictionary)(object)_properties); return new LogEvent(Timestamp, Level, Exception, MessageTemplate, properties, TraceId.GetValueOrDefault(), SpanId.GetValueOrDefault()); } } public enum LogEventLevel { Verbose, Debug, Information, Warning, Error, Fatal } public class LogEventProperty { [field: CompilerGenerated] public string Name { [CompilerGenerated] get; } [field: CompilerGenerated] public LogEventPropertyValue Value { [CompilerGenerated] get; } public LogEventProperty(string name, LogEventPropertyValue value) { Guard.AgainstNull(value, "value"); EnsureValidName(name); Name = name; Value = value; } internal LogEventProperty(EventProperty property) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (property.Equals(EventProperty.None)) { throw new ArgumentNullException("property"); } Name = property.Name; Value = property.Value; } public static bool IsValidName([NotNullWhen(true)] string? name) { return !string.IsNullOrWhiteSpace(name); } [MethodImpl(256)] internal static void EnsureValidName(string name) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) Guard.AgainstNull(name, "name"); if (!IsValidName(name)) { throw new ArgumentException("Property name must not be empty or whitespace.", "name"); } } } public abstract class LogEventPropertyValue : System.IFormattable { public abstract void Render(TextWriter output, string? format = null, IFormatProvider? formatProvider = null); public virtual string ToString() { return ToString(null, null); } public string ToString(string? format, IFormatProvider? formatProvider) { StringWriter orCreate = ReusableStringWriter.GetOrCreate(); try { Render((TextWriter)(object)orCreate, format, formatProvider); return ((object)orCreate).ToString(); } finally { ((System.IDisposable)orCreate)?.Dispose(); } } } public class MessageTemplate { [field: CompilerGenerated] public static MessageTemplate Empty { [CompilerGenerated] get; } = new MessageTemplate(Enumerable.Empty()); [field: CompilerGenerated] public string Text { [CompilerGenerated] get; } public System.Collections.Generic.IEnumerable Tokens => TokenArray; [field: CompilerGenerated] internal MessageTemplateToken[] TokenArray { [CompilerGenerated] get; } [field: CompilerGenerated] internal PropertyToken[]? NamedProperties { [CompilerGenerated] get; } [field: CompilerGenerated] internal PropertyToken[]? PositionalProperties { [CompilerGenerated] get; } public MessageTemplate(System.Collections.Generic.IEnumerable tokens) : this(string.Concat(tokens), tokens) { } public MessageTemplate(string text, System.Collections.Generic.IEnumerable tokens) { Text = Guard.AgainstNull(text, "text"); TokenArray = Enumerable.ToArray(Guard.AgainstNull(tokens, "tokens")); PropertyToken[] elementsOfTypeToArray = GetElementsOfTypeToArray(TokenArray); if (elementsOfTypeToArray.Length == 0) { return; } bool flag = true; bool flag2 = false; PropertyToken[] array = elementsOfTypeToArray; for (int i = 0; i < array.Length; i++) { if (array[i].IsPositional) { flag2 = true; } else { flag = false; } } if (flag) { PositionalProperties = elementsOfTypeToArray; return; } if (flag2) { SelfLog.WriteLine("Message template is malformed: {0}", text); } NamedProperties = elementsOfTypeToArray; } private static TResult[] GetElementsOfTypeToArray(MessageTemplateToken[] tokens) where TResult : class { List val = new List(tokens.Length / 2); for (int i = 0; i < tokens.Length; i++) { if (tokens[i] is TResult val2) { val.Add(val2); } } return val.ToArray(); } public virtual string ToString() { return Text; } public string Render(IReadOnlyDictionary properties, IFormatProvider? formatProvider = null) { StringWriter orCreate = ReusableStringWriter.GetOrCreate(formatProvider); try { Render(properties, (TextWriter)(object)orCreate, formatProvider); return ((object)orCreate).ToString(); } finally { ((System.IDisposable)orCreate)?.Dispose(); } } public void Render(IReadOnlyDictionary properties, TextWriter output, IFormatProvider? formatProvider = null) { Guard.AgainstNull>(properties, "properties"); Guard.AgainstNull(output, "output"); MessageTemplateRenderer.Render(this, properties, output, null, formatProvider); } } public class ScalarValue : LogEventPropertyValue { [field: CompilerGenerated] public static ScalarValue Null { [CompilerGenerated] get; } = new ScalarValue(null); [field: CompilerGenerated] public object? Value { [CompilerGenerated] get; } public ScalarValue(object? value) { Value = value; } public override void Render(TextWriter output, string? format = null, IFormatProvider? formatProvider = null) { Render(Value, output, format, formatProvider); } internal static void Render(object? value, TextWriter output, string? format = null, IFormatProvider? formatProvider = null) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown Guard.AgainstNull(output, "output"); if (value == null) { output.Write("null"); return; } if (value is string text) { if (format != "l") { output.Write('"'); output.Write(text.Replace("\"", "\\\"")); output.Write('"'); } else { output.Write(text); } return; } ICustomFormatter val = (ICustomFormatter)((formatProvider != null) ? formatProvider.GetFormat(typeof(ICustomFormatter)) : null); if (val != null) { output.Write(val.Format(format, value, formatProvider)); } else if (value is System.IFormattable formattable) { output.Write(formattable.ToString(format, (IFormatProvider)(((object)formatProvider) ?? ((object)CultureInfo.InvariantCulture)))); } else { output.Write(value.ToString()); } } public virtual bool Equals(object? obj) { if (obj is ScalarValue scalarValue) { return object.Equals(Value, scalarValue.Value); } return false; } public virtual int GetHashCode() { if (Value == null) { return 0; } return Value.GetHashCode(); } } public class SequenceValue : LogEventPropertyValue { private readonly LogEventPropertyValue[] _elements; [field: CompilerGenerated] public static SequenceValue Empty { [CompilerGenerated] get; } = new SequenceValue(System.Array.Empty()); public System.Collections.Generic.IReadOnlyList Elements => _elements; public SequenceValue(System.Collections.Generic.IEnumerable elements) { Guard.AgainstNull(elements, "elements"); _elements = Enumerable.ToArray(elements); } internal SequenceValue(LogEventPropertyValue[] elements) { Guard.AgainstNull(elements, "elements"); _elements = elements; } public override void Render(TextWriter output, string? format = null, IFormatProvider? formatProvider = null) { Guard.AgainstNull(output, "output"); output.Write('['); int num = _elements.Length - 1; for (int i = 0; i < num; i++) { _elements[i].Render(output, format, formatProvider); output.Write(", "); } if (_elements.Length != 0) { _elements[_elements.Length - 1].Render(output, format, formatProvider); } output.Write(']'); } } public class StructureValue : LogEventPropertyValue { private readonly LogEventProperty[] _properties; [field: CompilerGenerated] public string? TypeTag { [CompilerGenerated] get; } public System.Collections.Generic.IReadOnlyList Properties => _properties; public StructureValue(System.Collections.Generic.IEnumerable properties, string? typeTag = null) { Guard.AgainstNull(properties, "properties"); TypeTag = typeTag; _properties = Enumerable.ToArray(properties); } public override void Render(TextWriter output, string? format = null, IFormatProvider? formatProvider = null) { Guard.AgainstNull(output, "output"); if (TypeTag != null) { output.Write(TypeTag); output.Write(' '); } output.Write("{ "); int num = _properties.Length - 1; for (int i = 0; i < num; i++) { LogEventProperty property = _properties[i]; Render(output, property, formatProvider); output.Write(", "); } if (_properties.Length != 0) { LogEventProperty property2 = _properties[_properties.Length - 1]; Render(output, property2, formatProvider); } output.Write(" }"); } private static void Render(TextWriter output, LogEventProperty property, IFormatProvider? formatProvider = null) { output.Write(property.Name); output.Write(": "); property.Value.Render(output, null, formatProvider); } } } namespace Serilog.Debugging { public class LoggingFailedException : System.Exception { public LoggingFailedException(string message) : base(message) { } } public static class SelfLog { private static Action? _output; public static void Enable(TextWriter output) { TextWriter output2 = output; Guard.AgainstNull(output2, "output"); Enable((Action)delegate(string m) { output2.WriteLine(m); output2.Flush(); }); } public static void Enable(Action output) { _output = Guard.AgainstNull>(output, "output"); } public static void Disable() { _output = null; } public static void WriteLine(string format, object? arg0 = null, object? arg1 = null, object? arg2 = null) { _output?.Invoke(string.Format(System.DateTime.UtcNow.ToString("o") + " " + format, arg0, arg1, arg2)); } } } namespace Serilog.Data { public abstract class LogEventPropertyValueRewriter : LogEventPropertyValueVisitor { protected override LogEventPropertyValue VisitScalarValue(TState state, ScalarValue scalar) { return Guard.AgainstNull(scalar, "scalar"); } protected override LogEventPropertyValue VisitSequenceValue(TState state, SequenceValue sequence) { Guard.AgainstNull(sequence, "sequence"); for (int i = 0; i < ((System.Collections.Generic.IReadOnlyCollection)sequence.Elements).Count; i++) { LogEventPropertyValue logEventPropertyValue = sequence.Elements[i]; if (logEventPropertyValue != Visit(state, logEventPropertyValue)) { LogEventPropertyValue[] array = new LogEventPropertyValue[((System.Collections.Generic.IReadOnlyCollection)sequence.Elements).Count]; for (int j = 0; j < i; j++) { array[j] = sequence.Elements[j]; } for (int k = i; k < array.Length; k++) { array[k] = Visit(state, sequence.Elements[k]); } return new SequenceValue(array); } } return sequence; } protected override LogEventPropertyValue VisitStructureValue(TState state, StructureValue structure) { Guard.AgainstNull(structure, "structure"); for (int i = 0; i < ((System.Collections.Generic.IReadOnlyCollection)structure.Properties).Count; i++) { LogEventProperty logEventProperty = structure.Properties[i]; if (logEventProperty.Value != Visit(state, logEventProperty.Value)) { LogEventProperty[] array = new LogEventProperty[((System.Collections.Generic.IReadOnlyCollection)structure.Properties).Count]; for (int j = 0; j < i; j++) { array[j] = structure.Properties[j]; } for (int k = i; k < array.Length; k++) { LogEventProperty logEventProperty2 = structure.Properties[k]; array[k] = new LogEventProperty(logEventProperty2.Name, Visit(state, logEventProperty2.Value)); } return new StructureValue(array, structure.TypeTag); } } return structure; } protected override LogEventPropertyValue VisitDictionaryValue(TState state, DictionaryValue dictionary) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Guard.AgainstNull(dictionary, "dictionary"); System.Collections.Generic.IEnumerator> enumerator = ((System.Collections.Generic.IEnumerable>)dictionary.Elements).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { KeyValuePair current = enumerator.Current; if (current.Value == Visit(state, current.Value)) { continue; } Dictionary val = new Dictionary(((System.Collections.Generic.IReadOnlyCollection>)dictionary.Elements).Count); System.Collections.Generic.IEnumerator> enumerator2 = ((System.Collections.Generic.IEnumerable>)dictionary.Elements).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator2).MoveNext()) { KeyValuePair current2 = enumerator2.Current; val[current2.Key] = Visit(state, current2.Value); } } finally { ((System.IDisposable)enumerator2)?.Dispose(); } return new DictionaryValue((System.Collections.Generic.IEnumerable>)val); } return dictionary; } finally { ((System.IDisposable)enumerator)?.Dispose(); } } protected override LogEventPropertyValue VisitUnsupportedValue(TState state, LogEventPropertyValue value) { return value; } } public abstract class LogEventPropertyValueVisitor { protected virtual TResult Visit(TState state, LogEventPropertyValue value) { Guard.AgainstNull(value, "value"); if (value is ScalarValue scalar) { return VisitScalarValue(state, scalar); } if (value is SequenceValue sequence) { return VisitSequenceValue(state, sequence); } if (value is StructureValue structure) { return VisitStructureValue(state, structure); } if (value is DictionaryValue dictionary) { return VisitDictionaryValue(state, dictionary); } return VisitUnsupportedValue(state, value); } protected abstract TResult VisitScalarValue(TState state, ScalarValue scalar); protected abstract TResult VisitSequenceValue(TState state, SequenceValue sequence); protected abstract TResult VisitStructureValue(TState state, StructureValue structure); protected abstract TResult VisitDictionaryValue(TState state, DictionaryValue dictionary); protected virtual TResult VisitUnsupportedValue(TState state, LogEventPropertyValue value) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) Guard.AgainstNull(value, "value"); throw new NotSupportedException($"The value {value} is not of a type supported by this visitor."); } } } namespace Serilog.Core { public static class Constants { public const string SourceContextPropertyName = "SourceContext"; } [AttributeUsage(/*Could not decode attribute arguments.*/)] internal sealed class CustomDefaultMethodImplementationAttribute : System.Attribute { } public interface IBatchedLogEventSink { System.Threading.Tasks.Task EmitBatchAsync(System.Collections.Generic.IReadOnlyCollection batch); System.Threading.Tasks.Task OnEmptyBatchAsync() { return System.Threading.Tasks.Task.CompletedTask; } } public interface IDestructuringPolicy { bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory, [NotNullWhen(true)] out LogEventPropertyValue? result); } public interface ILogEventEnricher { void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory); } public interface ILogEventFilter { bool IsEnabled(LogEvent logEvent); } public interface ILogEventPropertyFactory { LogEventProperty CreateProperty(string name, object? value, bool destructureObjects = false); } public interface ILogEventPropertyValueFactory { LogEventPropertyValue CreatePropertyValue(object? value, bool destructureObjects = false); } public interface ILogEventSink { void Emit(LogEvent logEvent); } internal interface IMessageTemplateParser { MessageTemplate Parse(string messageTemplate); } internal interface IScalarConversionPolicy { bool TryConvertToScalar(object value, [NotNullWhen(true)] out ScalarValue? result); } internal class LevelOverrideMap { private readonly struct LevelOverride { [field: CompilerGenerated] public string Context { [CompilerGenerated] get; } [field: CompilerGenerated] public LoggingLevelSwitch LevelSwitch { [CompilerGenerated] get; } public LevelOverride(string context, LoggingLevelSwitch levelSwitch) { Context = context; LevelSwitch = levelSwitch; } } private readonly LogEventLevel _defaultMinimumLevel; private readonly LoggingLevelSwitch? _defaultLevelSwitch; private readonly LevelOverride[] _overrides; public LevelOverrideMap(IDictionary overrides, LogEventLevel defaultMinimumLevel, LoggingLevelSwitch? defaultLevelSwitch) { Guard.AgainstNull>(overrides, "overrides"); _defaultLevelSwitch = defaultLevelSwitch; _defaultMinimumLevel = ((defaultLevelSwitch == null) ? defaultMinimumLevel : LogEventLevel.Verbose); _overrides = Enumerable.ToArray(Enumerable.Select, LevelOverride>((System.Collections.Generic.IEnumerable>)Enumerable.OrderByDescending, string>((System.Collections.Generic.IEnumerable>)overrides, (Func, string>)((KeyValuePair o) => o.Key)), (Func, LevelOverride>)((KeyValuePair o) => new LevelOverride(o.Key, o.Value)))); } public unsafe void GetEffectiveLevel(System.ReadOnlySpan context, out LogEventLevel minimumLevel, out LoggingLevelSwitch? levelSwitch) { LevelOverride[] overrides = _overrides; for (int i = 0; i < overrides.Length; i++) { LevelOverride levelOverride = overrides[i]; if ((context.Length == levelOverride.Context.Length || (context.Length > levelOverride.Context.Length && *(ushort*)context[levelOverride.Context.Length] == 46)) && MemoryExtensions.StartsWith(context, string.op_Implicit(levelOverride.Context), (StringComparison)5)) { minimumLevel = LogEventLevel.Verbose; levelSwitch = levelOverride.LevelSwitch; return; } } minimumLevel = _defaultMinimumLevel; levelSwitch = _defaultLevelSwitch; } } public sealed class Logger : ILogger, ILogEventSink, System.IDisposable, System.IAsyncDisposable { private static readonly object[] NoPropertyValues = System.Array.Empty(); private static readonly LogEventProperty[] NoProperties = System.Array.Empty(); private readonly MessageTemplateProcessor _messageTemplateProcessor; private readonly ILogEventSink _sink; private readonly Action? _dispose; private readonly Func? _disposeAsync; private readonly ILogEventEnricher _enricher; private readonly LogEventLevel _minimumLevel; private readonly LoggingLevelSwitch? _levelSwitch; private readonly LevelOverrideMap? _overrideMap; internal bool HasOverrideMap => _overrideMap != null; [field: CompilerGenerated] public static ILogger None { [CompilerGenerated] get; } = new SilentLogger(); internal Logger(MessageTemplateProcessor messageTemplateProcessor, LogEventLevel minimumLevel, LoggingLevelSwitch? levelSwitch, ILogEventSink sink, ILogEventEnricher enricher, Action? dispose, Func? disposeAsync, LevelOverrideMap? overrideMap) { _messageTemplateProcessor = messageTemplateProcessor; _minimumLevel = minimumLevel; _sink = sink; _dispose = dispose; _disposeAsync = disposeAsync; _levelSwitch = levelSwitch; _overrideMap = overrideMap; _enricher = enricher; } public ILogger ForContext(ILogEventEnricher enricher) { if (enricher == null) { return this; } return new Logger(_messageTemplateProcessor, _minimumLevel, _levelSwitch, this, enricher, null, null, _overrideMap); } public ILogger ForContext(System.Collections.Generic.IEnumerable enrichers) { if (enrichers == null) { return this; } return ForContext(new SafeAggregateEnricher(enrichers)); } public ILogger ForContext(string propertyName, object? value, bool destructureObjects = false) { if (!LogEventProperty.IsValidName(propertyName)) { SelfLog.WriteLine("Attempt to call ForContext() with invalid property name `{0}` (value: `{1}`)", propertyName, value); return this; } LogEventPropertyValue value2 = _messageTemplateProcessor.CreatePropertyValue(value, destructureObjects); EventProperty eventProperty = new EventProperty(propertyName, value2); FixedPropertyEnricher enricher = new FixedPropertyEnricher(in eventProperty); LogEventLevel minimumLevel; LoggingLevelSwitch levelSwitch; if (_overrideMap != null && propertyName == "SourceContext" && value is string text) { _overrideMap.GetEffectiveLevel(string.op_Implicit(text), out minimumLevel, out levelSwitch); } else { minimumLevel = _minimumLevel; levelSwitch = _levelSwitch; } return new Logger(_messageTemplateProcessor, minimumLevel, levelSwitch, this, enricher, null, null, _overrideMap); } public ILogger ForContext(System.Type source) { if (source == (System.Type)null) { return this; } return ForContext("SourceContext", source.FullName); } public ILogger ForContext() { return ForContext(typeof(TSource)); } [MessageTemplateFormatMethod("messageTemplate")] public void Write(LogEventLevel level, string messageTemplate) { if (IsEnabled(level)) { Write(level, messageTemplate, NoPropertyValues); } } [MessageTemplateFormatMethod("messageTemplate")] public void Write(LogEventLevel level, string messageTemplate, T propertyValue) { if (IsEnabled(level)) { System.Span span = default(PropertiesInlineArray).AsSpan(1); span[0] = propertyValue; Write(level, messageTemplate, System.Span.op_Implicit(span)); } } [MessageTemplateFormatMethod("messageTemplate")] public void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { if (IsEnabled(level)) { System.Span span = default(PropertiesInlineArray).AsSpan(2); span[0] = propertyValue0; span[1] = propertyValue1; Write(level, messageTemplate, System.Span.op_Implicit(span)); } } [MessageTemplateFormatMethod("messageTemplate")] public void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { if (IsEnabled(level)) { System.Span span = default(PropertiesInlineArray).AsSpan(3); span[0] = propertyValue0; span[1] = propertyValue1; span[2] = propertyValue2; Write(level, messageTemplate, System.Span.op_Implicit(span)); } } [MessageTemplateFormatMethod("messageTemplate")] public void Write(LogEventLevel level, string messageTemplate, params object?[]? propertyValues) { Write(level, (System.Exception?)null, messageTemplate, propertyValues); } private void Write(LogEventLevel level, string messageTemplate, System.ReadOnlySpan propertyValues) { Write(level, (System.Exception?)null, messageTemplate, propertyValues); } public bool IsEnabled(LogEventLevel level) { if (level < _minimumLevel) { return false; } if (_levelSwitch != null) { return level >= _levelSwitch.MinimumLevel; } return true; } [MessageTemplateFormatMethod("messageTemplate")] public void Write(LogEventLevel level, System.Exception? exception, string messageTemplate) { if (IsEnabled(level)) { Write(level, exception, messageTemplate, NoPropertyValues); } } [MessageTemplateFormatMethod("messageTemplate")] public void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, T propertyValue) { if (IsEnabled(level)) { System.Span span = default(PropertiesInlineArray).AsSpan(1); span[0] = propertyValue; Write(level, exception, messageTemplate, System.Span.op_Implicit(span)); } } [MessageTemplateFormatMethod("messageTemplate")] public void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { if (IsEnabled(level)) { System.Span span = default(PropertiesInlineArray).AsSpan(2); span[0] = propertyValue0; span[1] = propertyValue1; Write(level, exception, messageTemplate, System.Span.op_Implicit(span)); } } [MessageTemplateFormatMethod("messageTemplate")] public void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { if (IsEnabled(level)) { System.Span span = default(PropertiesInlineArray).AsSpan(3); span[0] = propertyValue0; span[1] = propertyValue1; span[2] = propertyValue2; Write(level, exception, messageTemplate, System.Span.op_Implicit(span)); } } [MessageTemplateFormatMethod("messageTemplate")] public void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) if (IsEnabled(level) && messageTemplate != null) { if (propertyValues != null && ((object)propertyValues).GetType() != typeof(object[])) { propertyValues = new object[1] { propertyValues }; } DateTimeOffset now = DateTimeOffset.Now; System.Span span = ((propertyValues == null) ? System.Span.Empty : MemoryExtensions.AsSpan(propertyValues)); _messageTemplateProcessor.Process(messageTemplate, System.Span.op_Implicit(span), out MessageTemplate parsedTemplate, out EventProperty[] properties); Activity current = Activity.Current; LogEvent logEvent = new LogEvent(now, level, exception, parsedTemplate, properties, (ActivityTraceId)((current != null) ? current.TraceId : default(ActivityTraceId)), (ActivitySpanId)((current != null) ? current.SpanId : default(ActivitySpanId))); Dispatch(logEvent); } } [MessageTemplateFormatMethod("messageTemplate")] private void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, System.ReadOnlySpan propertyValues) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (IsEnabled(level) && messageTemplate != null) { DateTimeOffset now = DateTimeOffset.Now; _messageTemplateProcessor.Process(messageTemplate, propertyValues, out MessageTemplate parsedTemplate, out EventProperty[] properties); Activity current = Activity.Current; LogEvent logEvent = new LogEvent(now, level, exception, parsedTemplate, properties, (ActivityTraceId)((current != null) ? current.TraceId : default(ActivityTraceId)), (ActivitySpanId)((current != null) ? current.SpanId : default(ActivitySpanId))); Dispatch(logEvent); } } public void Write(LogEvent logEvent) { if (logEvent != null && IsEnabled(logEvent.Level)) { Dispatch(logEvent); } } void ILogEventSink.Emit(LogEvent logEvent) { Guard.AgainstNull(logEvent, "logEvent"); Dispatch(logEvent); } private void Dispatch(LogEvent logEvent) { try { _enricher.Enrich(logEvent, _messageTemplateProcessor); } catch (System.Exception arg) { SelfLog.WriteLine("Exception {0} caught while enriching {1} with {2}.", arg, logEvent, _enricher); } _sink.Emit(logEvent); } [MessageTemplateFormatMethod("messageTemplate")] public void Verbose(string messageTemplate) { Write(LogEventLevel.Verbose, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Verbose(string messageTemplate, T propertyValue) { Write(LogEventLevel.Verbose, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public void Verbose(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Verbose, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public void Verbose(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Verbose, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public void Verbose(string messageTemplate, params object?[]? propertyValues) { Verbose((System.Exception?)null, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Verbose(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Verbose, exception, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Verbose(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Verbose, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public void Verbose(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Verbose, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public void Verbose(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Verbose, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public void Verbose(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Write(LogEventLevel.Verbose, exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Debug(string messageTemplate) { Write(LogEventLevel.Debug, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Debug(string messageTemplate, T propertyValue) { Write(LogEventLevel.Debug, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public void Debug(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Debug, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public void Debug(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Debug, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public void Debug(string messageTemplate, params object?[]? propertyValues) { Debug((System.Exception?)null, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Debug(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Debug, exception, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Debug(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Debug, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public void Debug(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Debug, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public void Debug(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Debug, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public void Debug(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Write(LogEventLevel.Debug, exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Information(string messageTemplate) { Write(LogEventLevel.Information, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Information(string messageTemplate, T propertyValue) { Write(LogEventLevel.Information, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public void Information(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Information, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public void Information(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Information, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public void Information(string messageTemplate, params object?[]? propertyValues) { Information((System.Exception?)null, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Information(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Information, exception, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Information(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Information, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public void Information(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Information, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public void Information(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Information, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public void Information(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Write(LogEventLevel.Information, exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Warning(string messageTemplate) { Write(LogEventLevel.Warning, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Warning(string messageTemplate, T propertyValue) { Write(LogEventLevel.Warning, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public void Warning(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Warning, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public void Warning(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Warning, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public void Warning(string messageTemplate, params object?[]? propertyValues) { Warning((System.Exception?)null, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Warning(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Warning, exception, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Warning(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Warning, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public void Warning(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Warning, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public void Warning(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Warning, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public void Warning(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Write(LogEventLevel.Warning, exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Error(string messageTemplate) { Write(LogEventLevel.Error, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Error(string messageTemplate, T propertyValue) { Write(LogEventLevel.Error, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public void Error(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Error, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public void Error(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Error, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public void Error(string messageTemplate, params object?[]? propertyValues) { Error((System.Exception?)null, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Error(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Error, exception, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Error(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Error, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public void Error(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Error, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public void Error(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Error, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public void Error(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Write(LogEventLevel.Error, exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Fatal(string messageTemplate) { Write(LogEventLevel.Fatal, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Fatal(string messageTemplate, T propertyValue) { Write(LogEventLevel.Fatal, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public void Fatal(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Fatal, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public void Fatal(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Fatal, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public void Fatal(string messageTemplate, params object?[]? propertyValues) { Fatal((System.Exception?)null, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Fatal(System.Exception? exception, string messageTemplate) { Write(LogEventLevel.Fatal, exception, messageTemplate, NoPropertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public void Fatal(System.Exception? exception, string messageTemplate, T propertyValue) { Write(LogEventLevel.Fatal, exception, messageTemplate, propertyValue); } [MessageTemplateFormatMethod("messageTemplate")] public void Fatal(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { Write(LogEventLevel.Fatal, exception, messageTemplate, propertyValue0, propertyValue1); } [MessageTemplateFormatMethod("messageTemplate")] public void Fatal(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { Write(LogEventLevel.Fatal, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } [MessageTemplateFormatMethod("messageTemplate")] public void Fatal(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { Write(LogEventLevel.Fatal, exception, messageTemplate, propertyValues); } [MessageTemplateFormatMethod("messageTemplate")] public bool BindMessageTemplate(string messageTemplate, object?[]? propertyValues, [NotNullWhen(true)] out MessageTemplate? parsedTemplate, [NotNullWhen(true)] out System.Collections.Generic.IEnumerable? boundProperties) { if (messageTemplate == null) { parsedTemplate = null; boundProperties = null; return false; } _messageTemplateProcessor.Process(messageTemplate, System.ReadOnlySpan.op_Implicit(propertyValues ?? NoPropertyValues), out parsedTemplate, out EventProperty[] properties); System.Collections.Generic.IEnumerable enumerable; if (properties.Length != 0) { enumerable = Enumerable.Select((System.Collections.Generic.IEnumerable)properties, (Func)((EventProperty p) => new LogEventProperty(p))); } else { System.Collections.Generic.IEnumerable noProperties = NoProperties; enumerable = noProperties; } boundProperties = enumerable; return true; } public bool BindProperty(string? propertyName, object? value, bool destructureObjects, [NotNullWhen(true)] out LogEventProperty? property) { if (!LogEventProperty.IsValidName(propertyName)) { property = null; return false; } property = _messageTemplateProcessor.CreateProperty(propertyName, value, destructureObjects); return true; } public void Dispose() { Action? dispose = _dispose; if (dispose != null) { dispose.Invoke(); } } public System.Threading.Tasks.ValueTask DisposeAsync() { return _disposeAsync?.Invoke() ?? default(System.Threading.Tasks.ValueTask); } } public class LoggingLevelSwitch { private volatile LogEventLevel _minimumLevel; private readonly object _levelUpdateLock = new object(); [CompilerGenerated] private EventHandler? m_MinimumLevelChanged; public LogEventLevel MinimumLevel { get { return _minimumLevel; } set { lock (_levelUpdateLock) { LogEventLevel minimumLevel = _minimumLevel; if (minimumLevel != value) { _minimumLevel = value; this.MinimumLevelChanged?.Invoke((object)this, new LoggingLevelSwitchChangedEventArgs(minimumLevel, value)); } } } } public event EventHandler? MinimumLevelChanged { [CompilerGenerated] add { EventHandler val = this.m_MinimumLevelChanged; EventHandler val2; do { val2 = val; EventHandler val3 = (EventHandler)(object)System.Delegate.Combine((System.Delegate)(object)val2, (System.Delegate)(object)value); val = Interlocked.CompareExchange>(ref this.m_MinimumLevelChanged, val3, val2); } while (val != val2); } [CompilerGenerated] remove { EventHandler val = this.m_MinimumLevelChanged; EventHandler val2; do { val2 = val; EventHandler val3 = (EventHandler)(object)System.Delegate.Remove((System.Delegate)(object)val2, (System.Delegate)(object)value); val = Interlocked.CompareExchange>(ref this.m_MinimumLevelChanged, val3, val2); } while (val != val2); } } public LoggingLevelSwitch(LogEventLevel initialMinimumLevel = LogEventLevel.Information) { _minimumLevel = initialMinimumLevel; } } public class LoggingLevelSwitchChangedEventArgs : EventArgs { [field: CompilerGenerated] public LogEventLevel OldLevel { [CompilerGenerated] get; } [field: CompilerGenerated] public LogEventLevel NewLevel { [CompilerGenerated] get; } public LoggingLevelSwitchChangedEventArgs(LogEventLevel oldLevel, LogEventLevel newLevel) { OldLevel = oldLevel; NewLevel = newLevel; } } [AttributeUsage(/*Could not decode attribute arguments.*/)] public sealed class MessageTemplateFormatMethodAttribute : System.Attribute { [field: CompilerGenerated] public string MessageTemplateParameterName { [CompilerGenerated] get; [CompilerGenerated] private set; } public MessageTemplateFormatMethodAttribute(string messageTemplateParameterName) { MessageTemplateParameterName = messageTemplateParameterName; } } internal struct PropertiesInlineArray { private object? Object1; private object? Object2; private object? Object3; public System.Span AsSpan(int count) { if ((count < 0 || count > 3) ? true : false) { ThrowArgumentOutOfRangeException("count"); } return MemoryMarshal.CreateSpan(ref Object1, count); } [DoesNotReturn] private static void ThrowArgumentOutOfRangeException(string param) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) throw new ArgumentOutOfRangeException(param); } } } namespace Serilog.Core.Sinks { internal class AggregateSink : ILogEventSink { private readonly ILogEventSink[] _sinks; public AggregateSink(System.Collections.Generic.IEnumerable sinks) { Guard.AgainstNull(sinks, "sinks"); _sinks = Enumerable.ToArray(sinks); } public void Emit(LogEvent logEvent) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) List val = null; ILogEventSink[] sinks = _sinks; foreach (ILogEventSink logEventSink in sinks) { try { logEventSink.Emit(logEvent); } catch (System.Exception ex) { SelfLog.WriteLine("Caught exception while emitting to sink {0}: {1}", logEventSink, ex); if (val == null) { val = new List(); } val.Add(ex); } } if (val != null) { throw new AggregateException("Failed to emit a log event.", (System.Collections.Generic.IEnumerable)val); } } } internal sealed class ConditionalSink : ILogEventSink, System.IDisposable, System.IAsyncDisposable { private readonly ILogEventSink _wrapped; private readonly Func _condition; public ConditionalSink(ILogEventSink wrapped, Func condition) { _wrapped = Guard.AgainstNull(wrapped, "wrapped"); _condition = Guard.AgainstNull>(condition, "condition"); } public void Emit(LogEvent logEvent) { if (_condition.Invoke(logEvent)) { _wrapped.Emit(logEvent); } } public void Dispose() { (_wrapped as System.IDisposable)?.Dispose(); } public System.Threading.Tasks.ValueTask DisposeAsync() { if (_wrapped is System.IAsyncDisposable asyncDisposable) { return asyncDisposable.DisposeAsync(); } Dispose(); return default(System.Threading.Tasks.ValueTask); } } internal sealed class DisposeDelegatingSink : ILogEventSink, System.IDisposable, System.IAsyncDisposable { private readonly ILogEventSink _sink; private readonly System.IDisposable? _disposable; private readonly System.IAsyncDisposable? _asyncDisposable; public DisposeDelegatingSink(ILogEventSink sink, System.IDisposable? disposable, System.IAsyncDisposable? asyncDisposable) { _sink = sink; _disposable = disposable; _asyncDisposable = asyncDisposable; } public void Dispose() { _disposable?.Dispose(); } public System.Threading.Tasks.ValueTask DisposeAsync() { if (_asyncDisposable != null) { return _asyncDisposable.DisposeAsync(); } Dispose(); return default(System.Threading.Tasks.ValueTask); } public void Emit(LogEvent logEvent) { _sink.Emit(logEvent); } } internal sealed class DisposingAggregateSink : ILogEventSink, System.IDisposable, System.IAsyncDisposable { [StructLayout(3)] [CompilerGenerated] private struct d__4 : IAsyncStateMachine { public int <>1__state; public AsyncValueTaskMethodBuilder <>t__builder; public DisposingAggregateSink <>4__this; private ILogEventSink[] <>7__wrap1; private int <>7__wrap2; private ILogEventSink 5__4; private ConfiguredValueTaskAwaiter <>u__1; private void MoveNext() { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; DisposingAggregateSink disposingAggregateSink = <>4__this; try { if (num == 0) { goto IL_004f; } <>7__wrap1 = disposingAggregateSink._sinks; <>7__wrap2 = 0; goto IL_010e; IL_010e: System.IAsyncDisposable asyncDisposable = default(System.IAsyncDisposable); if (<>7__wrap2 < <>7__wrap1.Length) { 5__4 = <>7__wrap1[<>7__wrap2]; asyncDisposable = 5__4 as System.IAsyncDisposable; if (asyncDisposable != null) { goto IL_004f; } if (5__4 is System.IDisposable disposable) { try { disposable.Dispose(); } catch (System.Exception ex) { ReportDisposingException(5__4, ex); } } goto IL_00f9; } <>7__wrap1 = null; goto end_IL_000e; IL_004f: try { ConfiguredValueTaskAwaiter awaiter; if (num != 0) { ConfiguredValueTaskAwaitable val = asyncDisposable.DisposeAsync().ConfigureAwait(false); awaiter = ((ConfiguredValueTaskAwaitable)(ref val)).GetAwaiter(); if (!((ConfiguredValueTaskAwaiter)(ref awaiter)).IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter; ((AsyncValueTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__4>(ref awaiter, ref this); return; } } else { awaiter = <>u__1; <>u__1 = default(ConfiguredValueTaskAwaiter); num = (<>1__state = -1); } ((ConfiguredValueTaskAwaiter)(ref awaiter)).GetResult(); } catch (System.Exception ex2) { ReportDisposingException(5__4, ex2); } goto IL_00f9; IL_00f9: 5__4 = null; <>7__wrap2++; goto IL_010e; end_IL_000e:; } catch (System.Exception exception) { <>1__state = -2; ((AsyncValueTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; ((AsyncValueTaskMethodBuilder)(ref <>t__builder)).SetResult(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncValueTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } } private readonly ILogEventSink[] _sinks; public DisposingAggregateSink(System.Collections.Generic.IEnumerable sinks) { Guard.AgainstNull(sinks, "sinks"); _sinks = Enumerable.ToArray(sinks); } public void Emit(LogEvent logEvent) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) List val = null; ILogEventSink[] sinks = _sinks; foreach (ILogEventSink logEventSink in sinks) { try { logEventSink.Emit(logEvent); } catch (System.Exception ex) { SelfLog.WriteLine("Caught exception while emitting to sink {0}: {1}", logEventSink, ex); if (val == null) { val = new List(); } val.Add(ex); } } if (val != null) { throw new AggregateException("Failed to emit a log event.", (System.Collections.Generic.IEnumerable)val); } } public void Dispose() { ILogEventSink[] sinks = _sinks; foreach (ILogEventSink logEventSink in sinks) { if (logEventSink is System.IDisposable disposable) { try { disposable.Dispose(); } catch (System.Exception ex) { ReportDisposingException(logEventSink, ex); } } } } [AsyncStateMachine(typeof(d__4))] public System.Threading.Tasks.ValueTask DisposeAsync() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) d__4 d__ = default(d__4); d__.<>t__builder = AsyncValueTaskMethodBuilder.Create(); d__.<>4__this = this; d__.<>1__state = -1; ((AsyncValueTaskMethodBuilder)(ref d__.<>t__builder)).Start<d__4>(ref d__); return ((AsyncValueTaskMethodBuilder)(ref d__.<>t__builder)).Task; } private static void ReportDisposingException(ILogEventSink sink, System.Exception ex) { SelfLog.WriteLine("Caught exception while disposing sink {0}: {1}", sink, ex); } } internal class FilteringSink : ILogEventSink { private readonly ILogEventSink _sink; private readonly bool _propagateExceptions; private readonly ILogEventFilter[] _filters; public FilteringSink(ILogEventSink sink, System.Collections.Generic.IEnumerable filters, bool propagateExceptions) { _sink = Guard.AgainstNull(sink, "sink"); _filters = Enumerable.ToArray(Guard.AgainstNull(filters, "filters")); _propagateExceptions = propagateExceptions; } public void Emit(LogEvent logEvent) { try { ILogEventFilter[] filters = _filters; for (int i = 0; i < filters.Length; i++) { if (!filters[i].IsEnabled(logEvent)) { return; } } _sink.Emit(logEvent); } catch (System.Exception arg) { SelfLog.WriteLine("Caught exception while applying filters: {0}", arg); if (_propagateExceptions) { throw; } } } } internal sealed class RestrictedSink : ILogEventSink, System.IDisposable, System.IAsyncDisposable { private readonly ILogEventSink _sink; private readonly LoggingLevelSwitch _levelSwitch; public RestrictedSink(ILogEventSink sink, LoggingLevelSwitch levelSwitch) { _sink = Guard.AgainstNull(sink, "sink"); _levelSwitch = Guard.AgainstNull(levelSwitch, "levelSwitch"); } public void Emit(LogEvent logEvent) { Guard.AgainstNull(logEvent, "logEvent"); if (logEvent.Level >= _levelSwitch.MinimumLevel) { _sink.Emit(logEvent); } } public void Dispose() { (_sink as System.IDisposable)?.Dispose(); } public System.Threading.Tasks.ValueTask DisposeAsync() { if (_sink is System.IAsyncDisposable asyncDisposable) { return asyncDisposable.DisposeAsync(); } Dispose(); return default(System.Threading.Tasks.ValueTask); } } internal class SafeAggregateSink : ILogEventSink { private readonly ILogEventSink[] _sinks; public SafeAggregateSink(System.Collections.Generic.IEnumerable sinks) { Guard.AgainstNull(sinks, "sinks"); _sinks = Enumerable.ToArray(sinks); } public void Emit(LogEvent logEvent) { ILogEventSink[] sinks = _sinks; foreach (ILogEventSink logEventSink in sinks) { try { logEventSink.Emit(logEvent); } catch (System.Exception arg) { SelfLog.WriteLine("Caught exception while emitting to sink {0}: {1}", logEventSink, arg); } } } } internal sealed class SecondaryLoggerSink : ILogEventSink, System.IDisposable, System.IAsyncDisposable { private readonly ILogger _logger; private readonly bool _attemptDispose; public SecondaryLoggerSink(ILogger logger, bool attemptDispose = false) { _logger = Guard.AgainstNull(logger, "logger"); _attemptDispose = attemptDispose; } public void Emit(LogEvent logEvent) { Guard.AgainstNull(logEvent, "logEvent"); LogEvent logEvent2 = logEvent.Copy(); _logger.Write(logEvent2); } public void Dispose() { if (_attemptDispose) { (_logger as System.IDisposable)?.Dispose(); } } public System.Threading.Tasks.ValueTask DisposeAsync() { if (_logger is System.IAsyncDisposable asyncDisposable) { if (!_attemptDispose) { return default(System.Threading.Tasks.ValueTask); } return asyncDisposable.DisposeAsync(); } Dispose(); return default(System.Threading.Tasks.ValueTask); } } } namespace Serilog.Core.Sinks.Batching { internal sealed class BatchingSink : ILogEventSink, System.IDisposable, System.IAsyncDisposable { [StructLayout(3)] [CompilerGenerated] private struct d__16 : IAsyncStateMachine { public int <>1__state; public AsyncValueTaskMethodBuilder <>t__builder; public BatchingSink <>4__this; private ConfiguredTaskAwaiter <>u__1; private ConfiguredValueTaskAwaiter <>u__2; private void MoveNext() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; BatchingSink batchingSink = <>4__this; try { ConfiguredValueTaskAwaiter awaiter; if (num != 0) { if (num == 1) { awaiter = <>u__2; <>u__2 = default(ConfiguredValueTaskAwaiter); num = (<>1__state = -1); goto IL_010b; } batchingSink.SignalShutdown(); } try { ConfiguredTaskAwaiter awaiter2; if (num != 0) { ConfiguredTaskAwaitable val = batchingSink._runLoop.ConfigureAwait(false); awaiter2 = ((ConfiguredTaskAwaitable)(ref val)).GetAwaiter(); if (!((ConfiguredTaskAwaiter)(ref awaiter2)).IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter2; ((AsyncValueTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__16>(ref awaiter2, ref this); return; } } else { awaiter2 = <>u__1; <>u__1 = default(ConfiguredTaskAwaiter); num = (<>1__state = -1); } ((ConfiguredTaskAwaiter)(ref awaiter2)).GetResult(); } catch (System.Exception exception) { batchingSink.WriteToSelfLog("caught exception during async disposal", exception); } if (batchingSink._targetSink is System.IAsyncDisposable asyncDisposable) { ConfiguredValueTaskAwaitable val2 = asyncDisposable.DisposeAsync().ConfigureAwait(false); awaiter = ((ConfiguredValueTaskAwaitable)(ref val2)).GetAwaiter(); if (!((ConfiguredValueTaskAwaiter)(ref awaiter)).IsCompleted) { num = (<>1__state = 1); <>u__2 = awaiter; ((AsyncValueTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__16>(ref awaiter, ref this); return; } goto IL_010b; } (batchingSink._targetSink as System.IDisposable)?.Dispose(); goto end_IL_000e; IL_010b: ((ConfiguredValueTaskAwaiter)(ref awaiter)).GetResult(); end_IL_000e:; } catch (System.Exception exception2) { <>1__state = -2; ((AsyncValueTaskMethodBuilder)(ref <>t__builder)).SetException(exception2); return; } <>1__state = -2; ((AsyncValueTaskMethodBuilder)(ref <>t__builder)).SetResult(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncValueTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } } [StructLayout(3)] [CompilerGenerated] private struct d__13 : IAsyncStateMachine { public int <>1__state; public AsyncTaskMethodBuilder <>t__builder; public BatchingSink <>4__this; private bool 5__2; private System.Threading.Tasks.Task 5__3; private ConfiguredTaskAwaiter <>u__1; private object <>7__wrap3; private int <>7__wrap4; private ConfiguredTaskAwaiter <>u__2; private ConfiguredTaskAwaiter <>u__3; private void MoveNext() { //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; BatchingSink batchingSink = <>4__this; try { ConfiguredTaskAwaiter awaiter2; ConfiguredTaskAwaiter awaiter3; ConfiguredTaskAwaitable val; LogEvent logEvent2 = default(LogEvent); ConfiguredTaskAwaiter awaiter; LogEvent logEvent = default(LogEvent); bool flag; switch (num) { default: 5__2 = batchingSink._eagerlyEmitFirstEvent; goto IL_0034; case 0: awaiter2 = <>u__1; <>u__1 = default(ConfiguredTaskAwaiter); num = (<>1__state = -1); goto IL_0149; case 1: case 2: { try { if (num == 1) { awaiter3 = <>u__2; <>u__2 = default(ConfiguredTaskAwaiter); num = (<>1__state = -1); goto IL_01dd; } if (num != 2) { if (batchingSink._currentBatch.Count == 0) { val = batchingSink._targetSink.OnEmptyBatchAsync().ConfigureAwait(false); awaiter3 = ((ConfiguredTaskAwaitable)(ref val)).GetAwaiter(); if (!((ConfiguredTaskAwaiter)(ref awaiter3)).IsCompleted) { num = (<>1__state = 1); <>u__2 = awaiter3; ((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__13>(ref awaiter3, ref this); return; } goto IL_01dd; } 5__2 = false; val = batchingSink._targetSink.EmitBatchAsync((System.Collections.Generic.IReadOnlyCollection)batchingSink._currentBatch).ConfigureAwait(false); awaiter3 = ((ConfiguredTaskAwaitable)(ref val)).GetAwaiter(); if (!((ConfiguredTaskAwaiter)(ref awaiter3)).IsCompleted) { num = (<>1__state = 2); <>u__2 = awaiter3; ((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__13>(ref awaiter3, ref this); return; } } else { awaiter3 = <>u__2; <>u__2 = default(ConfiguredTaskAwaiter); num = (<>1__state = -1); } ((ConfiguredTaskAwaiter)(ref awaiter3)).GetResult(); batchingSink._currentBatch.Clear(); batchingSink._batchScheduler.MarkSuccess(); goto end_IL_015f; IL_01dd: ((ConfiguredTaskAwaiter)(ref awaiter3)).GetResult(); end_IL_015f:; } catch (System.Exception ex) { <>7__wrap3 = ex; <>7__wrap4 = 1; } int num2 = <>7__wrap4; if (num2 == 1) { System.Exception exception = (System.Exception)<>7__wrap3; batchingSink.WriteToSelfLog("failed emitting a batch", exception); batchingSink._batchScheduler.MarkFailure(); if (batchingSink._batchScheduler.ShouldDropBatch) { batchingSink.WriteToSelfLog("dropping the current batch"); batchingSink._currentBatch.Clear(); } if (batchingSink._batchScheduler.ShouldDropQueue) { batchingSink.WriteToSelfLog("dropping all queued events"); while (((Channel)(object)batchingSink._queue).Reader.TryRead(ref logEvent2) && !batchingSink._shutdownSignal.IsCancellationRequested) { } } awaiter = System.Threading.Tasks.Task.WhenAny(5__3, batchingSink._waitForShutdownSignal).ConfigureAwait(false).GetAwaiter(); if (!awaiter.IsCompleted) { num = (<>1__state = 3); <>u__3 = awaiter; ((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted, d__13>(ref awaiter, ref this); return; } goto IL_038d; } goto IL_0395; } case 3: awaiter = <>u__3; <>u__3 = default(ConfiguredTaskAwaiter); num = (<>1__state = -1); goto IL_038d; case 4: break; IL_0034: 5__3 = System.Threading.Tasks.Task.Delay(batchingSink._batchScheduler.NextInterval); goto IL_004a; IL_004a: while (batchingSink._currentBatch.Count < batchingSink._batchSizeLimit && !batchingSink._shutdownSignal.IsCancellationRequested && ((Channel)(object)batchingSink._queue).Reader.TryRead(ref logEvent)) { batchingSink._currentBatch.Enqueue(logEvent); } flag = ((batchingSink._currentBatch.Count < batchingSink._batchSizeLimit && !5__2) || batchingSink._currentBatch.Count == 0) && !batchingSink._shutdownSignal.IsCancellationRequested; if (flag) { awaiter2 = batchingSink.TryWaitToReadAsync(((Channel)(object)batchingSink._queue).Reader, 5__3, batchingSink._shutdownSignal.Token).ConfigureAwait(false).GetAwaiter(); if (!awaiter2.IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter2; ((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted, d__13>(ref awaiter2, ref this); return; } goto IL_0149; } goto IL_0151; IL_0151: if (flag) { goto IL_004a; } <>7__wrap4 = 0; goto case 1; IL_0149: flag = awaiter2.GetResult(); goto IL_0151; IL_038d: awaiter.GetResult(); goto IL_0395; IL_0395: <>7__wrap3 = null; 5__3 = null; if (batchingSink._shutdownSignal.IsCancellationRequested) { break; } goto IL_0034; } try { if (num != 4) { goto IL_0481; } awaiter3 = <>u__2; <>u__2 = default(ConfiguredTaskAwaiter); num = (<>1__state = -1); goto IL_046f; IL_0481: LogEvent logEvent3 = default(LogEvent); while (((Channel)(object)batchingSink._queue).Reader.TryPeek(ref logEvent2)) { while (batchingSink._currentBatch.Count < batchingSink._batchSizeLimit && ((Channel)(object)batchingSink._queue).Reader.TryRead(ref logEvent3)) { batchingSink._currentBatch.Enqueue(logEvent3); } if (batchingSink._currentBatch.Count == 0) { continue; } val = batchingSink._targetSink.EmitBatchAsync((System.Collections.Generic.IReadOnlyCollection)batchingSink._currentBatch).ConfigureAwait(false); awaiter3 = ((ConfiguredTaskAwaitable)(ref val)).GetAwaiter(); if (!((ConfiguredTaskAwaiter)(ref awaiter3)).IsCompleted) { num = (<>1__state = 4); <>u__2 = awaiter3; ((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__13>(ref awaiter3, ref this); return; } goto IL_046f; } goto end_IL_03b4; IL_046f: ((ConfiguredTaskAwaiter)(ref awaiter3)).GetResult(); batchingSink._currentBatch.Clear(); goto IL_0481; end_IL_03b4:; } catch (System.Exception exception2) { batchingSink.WriteToSelfLog("failed emitting a batch during shutdown; dropping remaining queued events", exception2); } } catch (System.Exception exception3) { <>1__state = -2; ((AsyncTaskMethodBuilder)(ref <>t__builder)).SetException(exception3); return; } <>1__state = -2; ((AsyncTaskMethodBuilder)(ref <>t__builder)).SetResult(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } } [StructLayout(3)] [CompilerGenerated] private struct d__14 : IAsyncStateMachine { public int <>1__state; public AsyncTaskMethodBuilder <>t__builder; public BatchingSink <>4__this; public ChannelReader reader; public CancellationToken cancellationToken; public System.Threading.Tasks.Task timeout; private System.Threading.Tasks.Task 5__2; private ConfiguredTaskAwaiter <>u__1; private TaskAwaiter <>u__2; private void MoveNext() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Invalid comparison between Unknown and I4 //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; BatchingSink batchingSink = <>4__this; bool result2; try { TaskAwaiter awaiter; ConfiguredTaskAwaiter awaiter2; if (num != 0) { if (num == 1) { awaiter = <>u__2; <>u__2 = default(TaskAwaiter); num = (<>1__state = -1); goto IL_0186; } 5__2 = batchingSink._cachedWaitToRead ?? reader.WaitToReadAsync(cancellationToken).AsTask(); batchingSink._cachedWaitToRead = null; awaiter2 = System.Threading.Tasks.Task.WhenAny(timeout, (System.Threading.Tasks.Task)5__2).ConfigureAwait(false).GetAwaiter(); if (!awaiter2.IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter2; <>t__builder.AwaitUnsafeOnCompleted, d__14>(ref awaiter2, ref this); return; } } else { awaiter2 = <>u__1; <>u__1 = default(ConfiguredTaskAwaiter); num = (<>1__state = -1); } System.Threading.Tasks.Task result = awaiter2.GetResult(); if (result != null && result.Exception != null && !result.IsCanceled) { batchingSink.WriteToSelfLog($"could not read from queue: {result.Exception}"); } if (result == timeout) { batchingSink._cachedWaitToRead = 5__2; result2 = false; } else { if ((int)((System.Threading.Tasks.Task)5__2).Status == 5) { awaiter = 5__2.GetAwaiter(); if (!awaiter.IsCompleted) { num = (<>1__state = 1); <>u__2 = awaiter; <>t__builder.AwaitUnsafeOnCompleted, d__14>(ref awaiter, ref this); return; } goto IL_0186; } result2 = false; } goto end_IL_000e; IL_0186: result2 = awaiter.GetResult(); end_IL_000e:; } catch (System.Exception exception) { <>1__state = -2; 5__2 = null; <>t__builder.SetException(exception); return; } <>1__state = -2; 5__2 = null; <>t__builder.SetResult(result2); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { <>t__builder.SetStateMachine(stateMachine); } } private readonly Channel _queue; private readonly object _stateLock = new object(); private readonly CancellationTokenSource _shutdownSignal = new CancellationTokenSource(); private readonly System.Threading.Tasks.Task _runLoop; private readonly IBatchedLogEventSink _targetSink; private readonly int _batchSizeLimit; private readonly bool _eagerlyEmitFirstEvent; private readonly FailureAwareBatchScheduler _batchScheduler; private readonly Queue _currentBatch = new Queue(); private readonly System.Threading.Tasks.Task _waitForShutdownSignal; private System.Threading.Tasks.Task? _cachedWaitToRead; public BatchingSink(IBatchedLogEventSink batchedSink, BatchingOptions options) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) if (options == null) { throw new ArgumentNullException("options"); } if (options.BatchSizeLimit <= 0) { throw new ArgumentOutOfRangeException("options", "The batch size limit must be greater than zero."); } if (options.BufferingTimeLimit <= TimeSpan.Zero) { throw new ArgumentOutOfRangeException("options", "The period must be greater than zero."); } _targetSink = batchedSink ?? throw new ArgumentNullException("batchedSink"); _batchSizeLimit = options.BatchSizeLimit; int? queueLimit = options.QueueLimit; Channel queue; if (queueLimit.HasValue) { int valueOrDefault = queueLimit.GetValueOrDefault(); queue = Channel.CreateBounded(new BoundedChannelOptions(valueOrDefault) { SingleReader = true }); } else { queue = Channel.CreateUnbounded(new UnboundedChannelOptions { SingleReader = true }); } _queue = queue; _batchScheduler = new FailureAwareBatchScheduler(options.BufferingTimeLimit); _eagerlyEmitFirstEvent = options.EagerlyEmitFirstEvent; _waitForShutdownSignal = System.Threading.Tasks.Task.Delay(Timeout.InfiniteTimeSpan, _shutdownSignal.Token).ContinueWith((Func)((System.Threading.Tasks.Task e) => e.Exception), (TaskContinuationOptions)327680); object obj; if (!ExecutionContext.IsFlowSuppressed()) { System.IDisposable disposable = (System.IDisposable)(object)ExecutionContext.SuppressFlow(); obj = disposable; } else { obj = null; } using (obj) { _runLoop = System.Threading.Tasks.Task.Run((Func)LoopAsync); } } public void Emit(LogEvent logEvent) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (logEvent == null) { throw new ArgumentNullException("logEvent"); } if (!_shutdownSignal.IsCancellationRequested) { ((Channel)(object)_queue).Writer.TryWrite(logEvent); } } [AsyncStateMachine(typeof(d__13))] private System.Threading.Tasks.Task LoopAsync() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) d__13 d__ = default(d__13); d__.<>t__builder = AsyncTaskMethodBuilder.Create(); d__.<>4__this = this; d__.<>1__state = -1; ((AsyncTaskMethodBuilder)(ref d__.<>t__builder)).Start<d__13>(ref d__); return ((AsyncTaskMethodBuilder)(ref d__.<>t__builder)).Task; } [AsyncStateMachine(typeof(d__14))] private async System.Threading.Tasks.Task TryWaitToReadAsync(ChannelReader reader, System.Threading.Tasks.Task timeout, CancellationToken cancellationToken) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) System.Threading.Tasks.Task waitToRead = _cachedWaitToRead ?? reader.WaitToReadAsync(cancellationToken).AsTask(); _cachedWaitToRead = null; System.Threading.Tasks.Task task = await System.Threading.Tasks.Task.WhenAny(timeout, (System.Threading.Tasks.Task)waitToRead).ConfigureAwait(false); if (task != null && task.Exception != null && !task.IsCanceled) { WriteToSelfLog($"could not read from queue: {task.Exception}"); } if (task == timeout) { _cachedWaitToRead = waitToRead; return false; } if ((int)((System.Threading.Tasks.Task)waitToRead).Status != 5) { return false; } return await waitToRead; } public void Dispose() { SignalShutdown(); try { _runLoop.Wait(); } catch (System.Exception exception) { WriteToSelfLog("caught exception during disposal", exception); } (_targetSink as System.IDisposable)?.Dispose(); } [AsyncStateMachine(typeof(d__16))] public System.Threading.Tasks.ValueTask DisposeAsync() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) d__16 d__ = default(d__16); d__.<>t__builder = AsyncValueTaskMethodBuilder.Create(); d__.<>4__this = this; d__.<>1__state = -1; ((AsyncValueTaskMethodBuilder)(ref d__.<>t__builder)).Start<d__16>(ref d__); return ((AsyncValueTaskMethodBuilder)(ref d__.<>t__builder)).Task; } private void SignalShutdown() { lock (_stateLock) { if (!_shutdownSignal.IsCancellationRequested) { ((Channel)(object)_queue).Writer.Complete((System.Exception)null); _shutdownSignal.Cancel(); } } } private void WriteToSelfLog(string message, System.Exception? exception = null) { string text = ((exception != null) ? $"{Environment.NewLine}{exception}" : ""); SelfLog.WriteLine($"BatchingSink ({_targetSink}): {message}{text}"); } } internal class FailureAwareBatchScheduler { private static readonly TimeSpan MinimumBackoffPeriod = TimeSpan.FromSeconds(5.0); private static readonly TimeSpan MaximumBackoffInterval = TimeSpan.FromMinutes(10.0); private const int FailuresBeforeDroppingBatch = 8; private const int FailuresBeforeDroppingQueue = 10; private readonly TimeSpan _period; private int _failuresSinceSuccessfulBatch; public TimeSpan NextInterval { get { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (_failuresSinceSuccessfulBatch <= 1) { return _period; } double num = Math.Pow(2.0, (double)(_failuresSinceSuccessfulBatch - 1)); long num2 = (long)((double)Math.Max(((TimeSpan)(ref _period)).Ticks, ((TimeSpan)(ref MinimumBackoffPeriod)).Ticks) * num); long num3 = Math.Min(((TimeSpan)(ref MaximumBackoffInterval)).Ticks, num2); return TimeSpan.FromTicks(Math.Max(((TimeSpan)(ref _period)).Ticks, num3)); } } public bool ShouldDropBatch => _failuresSinceSuccessfulBatch >= 8; public bool ShouldDropQueue => _failuresSinceSuccessfulBatch >= 10; public FailureAwareBatchScheduler(TimeSpan period) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (period < TimeSpan.Zero) { throw new ArgumentOutOfRangeException("period", "The batching period must be a positive timespan."); } _period = period; } public void MarkSuccess() { _failuresSinceSuccessfulBatch = 0; } public void MarkFailure() { _failuresSinceSuccessfulBatch++; } } } namespace Serilog.Core.Pipeline { internal class ByReferenceStringComparer : IEqualityComparer, IEqualityComparer { public static readonly ByReferenceStringComparer Instance = new ByReferenceStringComparer(); private ByReferenceStringComparer() { } public bool Equals(object? x, object? y) { return x == y; } public int GetHashCode(object obj) { return RuntimeHelpers.GetHashCode(obj); } public bool Equals(string? x, string? y) { return x == y; } public int GetHashCode(string obj) { return GetHashCode((object)obj); } } internal class MessageTemplateCache : IMessageTemplateParser { private readonly IMessageTemplateParser _innerParser; private readonly object _templatesLock = new object(); private readonly Hashtable _templates = new Hashtable((IEqualityComparer)(object)ByReferenceStringComparer.Instance); private const int MaxCacheItems = 1000; private const int MaxCachedTemplateLength = 1024; public MessageTemplateCache(IMessageTemplateParser innerParser) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown _innerParser = Guard.AgainstNull(innerParser, "innerParser"); } public MessageTemplate Parse(string messageTemplate) { Guard.AgainstNull(messageTemplate, "messageTemplate"); if (messageTemplate.Length > 1024) { return _innerParser.Parse(messageTemplate); } MessageTemplate messageTemplate2 = (MessageTemplate)_templates[(object)messageTemplate]; if (messageTemplate2 != null) { return messageTemplate2; } messageTemplate2 = _innerParser.Parse(messageTemplate); lock (_templatesLock) { if (_templates.Count == 1000) { _templates.Clear(); } _templates[(object)messageTemplate] = messageTemplate2; return messageTemplate2; } } } internal sealed class SilentLogger : ILogger { public ILogger ForContext(ILogEventEnricher enricher) { return this; } public ILogger ForContext(System.Collections.Generic.IEnumerable enrichers) { return this; } public ILogger ForContext(string propertyName, object? value, bool destructureObjects = false) { return this; } public ILogger ForContext() { return this; } public ILogger ForContext(System.Type source) { return this; } public void Write(LogEvent logEvent) { } public void Write(LogEventLevel level, string messageTemplate) { } public void Write(LogEventLevel level, string messageTemplate, T propertyValue) { } public void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { } public void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { } public void Write(LogEventLevel level, string messageTemplate, params object?[]? propertyValues) { } public void Write(LogEventLevel level, System.Exception? exception, string messageTemplate) { } public void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, T propertyValue) { } public void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { } public void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { } public void Write(LogEventLevel level, System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { } public bool IsEnabled(LogEventLevel level) { return false; } public void Verbose(string messageTemplate) { } public void Verbose(string messageTemplate, T propertyValue) { } public void Verbose(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { } public void Verbose(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { } public void Verbose(string messageTemplate, params object?[]? propertyValues) { } public void Verbose(System.Exception? exception, string messageTemplate) { } public void Verbose(System.Exception? exception, string messageTemplate, T propertyValue) { } public void Verbose(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { } public void Verbose(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { } public void Verbose(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { } public void Debug(string messageTemplate) { } public void Debug(string messageTemplate, T propertyValue) { } public void Debug(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { } public void Debug(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { } public void Debug(string messageTemplate, params object?[]? propertyValues) { } public void Debug(System.Exception? exception, string messageTemplate) { } public void Debug(System.Exception? exception, string messageTemplate, T propertyValue) { } public void Debug(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { } public void Debug(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { } public void Debug(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { } public void Information(string messageTemplate) { } public void Information(string messageTemplate, T propertyValue) { } public void Information(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { } public void Information(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { } public void Information(string messageTemplate, params object?[]? propertyValues) { } public void Information(System.Exception? exception, string messageTemplate) { } public void Information(System.Exception? exception, string messageTemplate, T propertyValue) { } public void Information(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { } public void Information(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { } public void Information(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { } public void Warning(string messageTemplate) { } public void Warning(string messageTemplate, T propertyValue) { } public void Warning(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { } public void Warning(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { } public void Warning(string messageTemplate, params object?[]? propertyValues) { } public void Warning(System.Exception? exception, string messageTemplate) { } public void Warning(System.Exception? exception, string messageTemplate, T propertyValue) { } public void Warning(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { } public void Warning(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { } public void Warning(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { } public void Error(string messageTemplate) { } public void Error(string messageTemplate, T propertyValue) { } public void Error(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { } public void Error(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { } public void Error(string messageTemplate, params object?[]? propertyValues) { } public void Error(System.Exception? exception, string messageTemplate) { } public void Error(System.Exception? exception, string messageTemplate, T propertyValue) { } public void Error(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { } public void Error(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { } public void Error(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { } public void Fatal(string messageTemplate) { } public void Fatal(string messageTemplate, T propertyValue) { } public void Fatal(string messageTemplate, T0 propertyValue0, T1 propertyValue1) { } public void Fatal(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { } public void Fatal(string messageTemplate, params object?[]? propertyValues) { } public void Fatal(System.Exception? exception, string messageTemplate) { } public void Fatal(System.Exception? exception, string messageTemplate, T propertyValue) { } public void Fatal(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { } public void Fatal(System.Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { } public void Fatal(System.Exception? exception, string messageTemplate, params object?[]? propertyValues) { } [MessageTemplateFormatMethod("messageTemplate")] public bool BindMessageTemplate(string messageTemplate, object?[]? propertyValues, [NotNullWhen(true)] out MessageTemplate? parsedTemplate, [NotNullWhen(true)] out System.Collections.Generic.IEnumerable? boundProperties) { parsedTemplate = null; boundProperties = null; return false; } public bool BindProperty(string? propertyName, object? value, bool destructureObjects, [NotNullWhen(true)] out LogEventProperty? property) { property = null; return false; } } } namespace Serilog.Core.Filters { internal class DelegateFilter : ILogEventFilter { private readonly Func _isEnabled; public DelegateFilter(Func isEnabled) { _isEnabled = Guard.AgainstNull>(isEnabled, "isEnabled"); } public bool IsEnabled(LogEvent logEvent) { Guard.AgainstNull(logEvent, "logEvent"); return _isEnabled.Invoke(logEvent); } } } namespace Serilog.Core.Enrichers { internal class ConditionalEnricher : ILogEventEnricher, System.IDisposable { private readonly ILogEventEnricher _wrapped; private readonly Func _condition; public ConditionalEnricher(ILogEventEnricher wrapped, Func condition) { _wrapped = Guard.AgainstNull(wrapped, "wrapped"); _condition = Guard.AgainstNull>(condition, "condition"); } public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { if (_condition.Invoke(logEvent)) { _wrapped.Enrich(logEvent, propertyFactory); } } public void Dispose() { (_wrapped as System.IDisposable)?.Dispose(); } } internal class EmptyEnricher : ILogEventEnricher { public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { } } internal class FixedPropertyEnricher : ILogEventEnricher { private readonly EventProperty _eventProperty; public FixedPropertyEnricher(in EventProperty eventProperty) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (eventProperty.Equals(EventProperty.None)) { throw new ArgumentNullException("eventProperty"); } _eventProperty = eventProperty; } public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { Guard.AgainstNull(logEvent, "logEvent"); logEvent.AddPropertyIfAbsent(in _eventProperty); } } public class PropertyEnricher : ILogEventEnricher { private readonly string _name; private readonly object? _value; private readonly bool _destructureObjects; public PropertyEnricher(string name, object? value, bool destructureObjects = false) { LogEventProperty.EnsureValidName(name); _name = name; _value = value; _destructureObjects = destructureObjects; } public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { Guard.AgainstNull(logEvent, "logEvent"); Guard.AgainstNull(propertyFactory, "propertyFactory"); logEvent.AddPropertyIfAbsent(propertyFactory, _name, _value, _destructureObjects); } } internal class SafeAggregateEnricher : ILogEventEnricher { private readonly ILogEventEnricher[] _enrichers; public SafeAggregateEnricher(System.Collections.Generic.IEnumerable enrichers) { Guard.AgainstNull(enrichers, "enrichers"); _enrichers = Enumerable.ToArray(enrichers); } public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { ILogEventEnricher[] enrichers = _enrichers; foreach (ILogEventEnricher logEventEnricher in enrichers) { try { logEventEnricher.Enrich(logEvent, propertyFactory); } catch (System.Exception arg) { SelfLog.WriteLine("Exception {0} caught while enriching {1} with {2}.", arg, logEvent, logEventEnricher); } } } } } namespace Serilog.Context { internal class EnricherStack : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { internal struct Enumerator : System.Collections.Generic.IEnumerator, System.Collections.IEnumerator, System.IDisposable { private readonly EnricherStack _stack; private EnricherStack _top; private ILogEventEnricher? _current; public ILogEventEnricher Current => _current; object System.Collections.IEnumerator.Current => _current; public Enumerator(EnricherStack stack) { _stack = stack; _top = stack; _current = null; } public bool MoveNext() { if (_top.IsEmpty) { return false; } _current = _top.Top; _top = _top._under; return true; } public void Reset() { _top = _stack; _current = null; } public void Dispose() { } } private readonly EnricherStack? _under; private readonly ILogEventEnricher? _top; [field: CompilerGenerated] public int Count { [CompilerGenerated] get; } [field: CompilerGenerated] public static EnricherStack Empty { [CompilerGenerated] get; } = new EnricherStack(); public bool IsEmpty => _under == null; public ILogEventEnricher Top => _top; private EnricherStack() { } private EnricherStack(EnricherStack under, ILogEventEnricher top) { _under = Guard.AgainstNull(under, "under"); Count = under.Count + 1; _top = top; } public Enumerator GetEnumerator() { return new Enumerator(this); } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { return new Enumerator(this); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return new Enumerator(this); } public EnricherStack Push(ILogEventEnricher t) { return new EnricherStack(this, t); } } public static class LogContext { private sealed class ContextStackBookmark : System.IDisposable { private readonly EnricherStack _bookmark; public ContextStackBookmark(EnricherStack bookmark) { _bookmark = bookmark; } public void Dispose() { Enrichers = _bookmark; } } private static readonly AsyncLocal Data = new AsyncLocal(); private static EnricherStack? Enrichers { get { return Data.Value; } set { Data.Value = value; } } public static System.IDisposable PushProperty(string name, object? value, bool destructureObjects = false) { return Push(new PropertyEnricher(name, value, destructureObjects)); } public static System.IDisposable Push(ILogEventEnricher enricher) { Guard.AgainstNull(enricher, "enricher"); EnricherStack orCreateEnricherStack = GetOrCreateEnricherStack(); ContextStackBookmark result = new ContextStackBookmark(orCreateEnricherStack); Enrichers = orCreateEnricherStack.Push(enricher); return result; } public static System.IDisposable Push(params ILogEventEnricher[] enrichers) { Guard.AgainstNull(enrichers, "enrichers"); EnricherStack enricherStack = GetOrCreateEnricherStack(); ContextStackBookmark result = new ContextStackBookmark(enricherStack); for (int i = 0; i < enrichers.Length; i++) { enricherStack = enricherStack.Push(enrichers[i]); } Enrichers = enricherStack; return result; } public static ILogEventEnricher Clone() { return new SafeAggregateEnricher(GetOrCreateEnricherStack()); } public static System.IDisposable Suspend() { ContextStackBookmark result = new ContextStackBookmark(GetOrCreateEnricherStack()); Enrichers = EnricherStack.Empty; return result; } public static void Reset() { if (Enrichers != null && Enrichers != EnricherStack.Empty) { Enrichers = EnricherStack.Empty; } } private static EnricherStack GetOrCreateEnricherStack() { EnricherStack enricherStack = Enrichers; if (enricherStack == null) { enricherStack = (Enrichers = EnricherStack.Empty); } return enricherStack; } internal static void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { EnricherStack enrichers = Enrichers; if (enrichers == null || enrichers == EnricherStack.Empty) { return; } foreach (ILogEventEnricher item in enrichers) { item.Enrich(logEvent, propertyFactory); } } } internal sealed class LogContextEnricher : ILogEventEnricher { public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { LogContext.Enrich(logEvent, propertyFactory); } } } namespace Serilog.Configuration { public class BatchingOptions { [field: CompilerGenerated] public bool EagerlyEmitFirstEvent { [CompilerGenerated] get; [CompilerGenerated] set; } = true; [field: CompilerGenerated] public int BatchSizeLimit { [CompilerGenerated] get; [CompilerGenerated] set; } = 1000; [field: CompilerGenerated] public TimeSpan BufferingTimeLimit { [CompilerGenerated] get; [CompilerGenerated] set; } = TimeSpan.FromSeconds(2.0); [field: CompilerGenerated] public int? QueueLimit { [CompilerGenerated] get; [CompilerGenerated] set; } = 100000; } public interface ILoggerSettings { void Configure(LoggerConfiguration loggerConfiguration); } public class LoggerAuditSinkConfiguration { private readonly LoggerSinkConfiguration _sinkConfiguration; internal LoggerAuditSinkConfiguration(LoggerConfiguration loggerConfiguration, Action addSink) { _sinkConfiguration = new LoggerSinkConfiguration(loggerConfiguration, addSink); } public LoggerConfiguration Sink(ILogEventSink logEventSink, LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose, LoggingLevelSwitch? levelSwitch = null) { return _sinkConfiguration.Sink(logEventSink, restrictedToMinimumLevel, levelSwitch); } public LoggerConfiguration Sink(LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose, LoggingLevelSwitch? levelSwitch = null) where TSink : ILogEventSink, new() { return _sinkConfiguration.Sink(restrictedToMinimumLevel, levelSwitch); } public LoggerConfiguration Logger(Action configureLogger, LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose, LoggingLevelSwitch? levelSwitch = null) { return _sinkConfiguration.Logger(configureLogger, restrictedToMinimumLevel, levelSwitch); } public LoggerConfiguration Logger(ILogger logger, LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose) { return _sinkConfiguration.Logger(logger, restrictedToMinimumLevel); } } public class LoggerDestructuringConfiguration { private readonly LoggerConfiguration _loggerConfiguration; private readonly Action _addScalar; private readonly Action _addDictionaryType; private readonly Action _addPolicy; private readonly Action _setMaximumDepth; private readonly Action _setMaximumStringLength; private readonly Action _setMaximumCollectionCount; internal LoggerDestructuringConfiguration(LoggerConfiguration loggerConfiguration, Action addScalar, Action addDictionaryType, Action addPolicy, Action setMaximumDepth, Action setMaximumStringLength, Action setMaximumCollectionCount) { _loggerConfiguration = Guard.AgainstNull(loggerConfiguration, "loggerConfiguration"); _addScalar = Guard.AgainstNull>(addScalar, "addScalar"); _addDictionaryType = Guard.AgainstNull>(addDictionaryType, "addDictionaryType"); _addPolicy = Guard.AgainstNull>(addPolicy, "addPolicy"); _setMaximumDepth = Guard.AgainstNull>(setMaximumDepth, "setMaximumDepth"); _setMaximumStringLength = Guard.AgainstNull>(setMaximumStringLength, "setMaximumStringLength"); _setMaximumCollectionCount = Guard.AgainstNull>(setMaximumCollectionCount, "setMaximumCollectionCount"); } public LoggerConfiguration AsScalar(System.Type scalarType) { Guard.AgainstNull(scalarType, "scalarType"); _addScalar.Invoke(scalarType); return _loggerConfiguration; } public LoggerConfiguration AsScalar() { return AsScalar(typeof(TScalar)); } public LoggerConfiguration With(params IDestructuringPolicy[] destructuringPolicies) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) Guard.AgainstNull(destructuringPolicies, "destructuringPolicies"); foreach (IDestructuringPolicy destructuringPolicy in destructuringPolicies) { if (destructuringPolicy == null) { throw new ArgumentException("Null policy is not allowed."); } _addPolicy.Invoke(destructuringPolicy); } return _loggerConfiguration; } public LoggerConfiguration With() where TDestructuringPolicy : IDestructuringPolicy, new() { return With(new TDestructuringPolicy()); } public LoggerConfiguration AsDictionary() where T : IDictionary { _addDictionaryType.Invoke(typeof(T)); return _loggerConfiguration; } public LoggerConfiguration ByTransforming(Func transformation) { Func transformation2 = transformation; Guard.AgainstNull>(transformation2, "transformation"); ProjectedDestructuringPolicy projectedDestructuringPolicy = new ProjectedDestructuringPolicy((System.Type t) => t == typeof(TValue), (object o) => transformation2.Invoke((TValue)o)); return With(projectedDestructuringPolicy); } public LoggerConfiguration ByTransformingWhere(Func predicate, Func transformation) { Func transformation2 = transformation; Guard.AgainstNull>(predicate, "predicate"); Guard.AgainstNull>(transformation2, "transformation"); ProjectedDestructuringPolicy projectedDestructuringPolicy = new ProjectedDestructuringPolicy(predicate, (object o) => transformation2.Invoke((TValue)o)); return With(projectedDestructuringPolicy); } public LoggerConfiguration ToMaximumDepth(int maximumDestructuringDepth) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (maximumDestructuringDepth < 0) { throw new ArgumentOutOfRangeException("maximumDestructuringDepth", "Maximum destructuring depth must be positive."); } _setMaximumDepth.Invoke(maximumDestructuringDepth); return _loggerConfiguration; } public LoggerConfiguration ToMaximumStringLength(int maximumStringLength) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (maximumStringLength < 2) { throw new ArgumentOutOfRangeException("maximumStringLength", (object)maximumStringLength, "Maximum string length must be at least two."); } _setMaximumStringLength.Invoke(maximumStringLength); return _loggerConfiguration; } public LoggerConfiguration ToMaximumCollectionCount(int maximumCollectionCount) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (maximumCollectionCount < 1) { throw new ArgumentOutOfRangeException("maximumCollectionCount", (object)maximumCollectionCount, "Maximum collection length must be at least one."); } _setMaximumCollectionCount.Invoke(maximumCollectionCount); return _loggerConfiguration; } } public class LoggerEnrichmentConfiguration { private readonly LoggerConfiguration _loggerConfiguration; private readonly Action _addEnricher; internal LoggerEnrichmentConfiguration(LoggerConfiguration loggerConfiguration, Action addEnricher) { _loggerConfiguration = Guard.AgainstNull(loggerConfiguration, "loggerConfiguration"); _addEnricher = Guard.AgainstNull>(addEnricher, "addEnricher"); } public LoggerConfiguration With(params ILogEventEnricher[] enrichers) { Guard.AgainstNull(enrichers, "enrichers"); foreach (ILogEventEnricher logEventEnricher in enrichers) { Guard.AgainstNull(logEventEnricher, "logEventEnricher"); _addEnricher.Invoke(logEventEnricher); } return _loggerConfiguration; } public LoggerConfiguration With() where TEnricher : ILogEventEnricher, new() { return With(new TEnricher()); } public LoggerConfiguration WithProperty(string name, object? value, bool destructureObjects = false) { return With(new PropertyEnricher(name, value, destructureObjects)); } public LoggerConfiguration FromLogContext() { return With(); } public LoggerConfiguration When(Func condition, Action configureEnricher) { Func condition2 = condition; Guard.AgainstNull>(condition2, "condition"); Guard.AgainstNull>(configureEnricher, "configureEnricher"); return Wrap(this, (ILogEventEnricher e) => new ConditionalEnricher(e, condition2), configureEnricher); } public LoggerConfiguration AtLevel(LogEventLevel enrichFromLevel, Action configureEnricher) { Guard.AgainstNull>(configureEnricher, "configureEnricher"); return Wrap(this, (ILogEventEnricher e) => new ConditionalEnricher(e, (LogEvent le) => le.Level >= enrichFromLevel), configureEnricher); } public LoggerConfiguration AtLevel(LoggingLevelSwitch levelSwitch, Action configureEnricher) { LoggingLevelSwitch levelSwitch2 = levelSwitch; Guard.AgainstNull>(configureEnricher, "configureEnricher"); return Wrap(this, (ILogEventEnricher e) => new ConditionalEnricher(e, (LogEvent le) => le.Level >= levelSwitch2.MinimumLevel), configureEnricher); } public static LoggerConfiguration Wrap(LoggerEnrichmentConfiguration loggerEnrichmentConfiguration, Func wrapEnricher, Action configureWrappedEnricher) { Guard.AgainstNull(loggerEnrichmentConfiguration, "loggerEnrichmentConfiguration"); Guard.AgainstNull>(wrapEnricher, "wrapEnricher"); Guard.AgainstNull>(configureWrappedEnricher, "configureWrappedEnricher"); List val = new List(); LoggerConfiguration loggerConfiguration = new LoggerConfiguration(); LoggerEnrichmentConfiguration loggerEnrichmentConfiguration3 = (loggerConfiguration.Enrich = new LoggerEnrichmentConfiguration(loggerConfiguration, val.Add)); configureWrappedEnricher.Invoke(loggerEnrichmentConfiguration3); if (val.Count == 0) { return loggerEnrichmentConfiguration._loggerConfiguration; } ILogEventEnricher logEventEnricher2; if (val.Count != 1) { ILogEventEnricher logEventEnricher = new SafeAggregateEnricher((System.Collections.Generic.IEnumerable)val); logEventEnricher2 = logEventEnricher; } else { logEventEnricher2 = Enumerable.Single((System.Collections.Generic.IEnumerable)val); } ILogEventEnricher logEventEnricher3 = logEventEnricher2; ILogEventEnricher logEventEnricher4 = wrapEnricher.Invoke(logEventEnricher3); if (!(logEventEnricher4 is System.IDisposable)) { SelfLog.WriteLine("Wrapping enricher {0} does not implement IDisposable; to ensure wrapped enrichers are properly disposed, wrappers should dispose their wrapped contents", logEventEnricher4); } return loggerEnrichmentConfiguration.With(logEventEnricher4); } } public class LoggerFilterConfiguration { private readonly LoggerConfiguration _loggerConfiguration; private readonly Action _addFilter; internal LoggerFilterConfiguration(LoggerConfiguration loggerConfiguration, Action addFilter) { _loggerConfiguration = Guard.AgainstNull(loggerConfiguration, "loggerConfiguration"); _addFilter = Guard.AgainstNull>(addFilter, "addFilter"); } public LoggerConfiguration With(params ILogEventFilter[] filters) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) Guard.AgainstNull(filters, "filters"); foreach (ILogEventFilter logEventFilter in filters) { if (logEventFilter == null) { throw new ArgumentException("Null filter is not allowed."); } _addFilter.Invoke(logEventFilter); } return _loggerConfiguration; } public LoggerConfiguration With() where TFilter : ILogEventFilter, new() { return With(new TFilter()); } public LoggerConfiguration ByExcluding(Func exclusionPredicate) { Func exclusionPredicate2 = exclusionPredicate; return With(new DelegateFilter((LogEvent logEvent) => !exclusionPredicate2.Invoke(logEvent))); } public LoggerConfiguration ByIncludingOnly(Func inclusionPredicate) { return With(new DelegateFilter(inclusionPredicate)); } } public class LoggerMinimumLevelConfiguration { private readonly LoggerConfiguration _loggerConfiguration; private readonly Action _setMinimum; private readonly Action _setLevelSwitch; private readonly Action _addOverride; internal LoggerMinimumLevelConfiguration(LoggerConfiguration loggerConfiguration, Action setMinimum, Action setLevelSwitch, Action addOverride) { _loggerConfiguration = Guard.AgainstNull(loggerConfiguration, "loggerConfiguration"); _setMinimum = Guard.AgainstNull>(setMinimum, "setMinimum"); _setLevelSwitch = setLevelSwitch; _addOverride = Guard.AgainstNull>(addOverride, "addOverride"); } public LoggerConfiguration Is(LogEventLevel minimumLevel) { _setMinimum.Invoke(minimumLevel); return _loggerConfiguration; } public LoggerConfiguration ControlledBy(LoggingLevelSwitch levelSwitch) { Guard.AgainstNull(levelSwitch, "levelSwitch"); _setLevelSwitch.Invoke(levelSwitch); return _loggerConfiguration; } public LoggerConfiguration Verbose() { return Is(LogEventLevel.Verbose); } public LoggerConfiguration Debug() { return Is(LogEventLevel.Debug); } public LoggerConfiguration Information() { return Is(LogEventLevel.Information); } public LoggerConfiguration Warning() { return Is(LogEventLevel.Warning); } public LoggerConfiguration Error() { return Is(LogEventLevel.Error); } public LoggerConfiguration Fatal() { return Is(LogEventLevel.Fatal); } public LoggerConfiguration Override(string source, LoggingLevelSwitch levelSwitch) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) Guard.AgainstNull(source, "source"); Guard.AgainstNull(levelSwitch, "levelSwitch"); string text = source.Trim(); if (text.Length == 0) { throw new ArgumentException("A source source must be provided.", "source"); } _addOverride.Invoke(text, levelSwitch); return _loggerConfiguration; } public LoggerConfiguration Override(string source, LogEventLevel minimumLevel) { return Override(source, new LoggingLevelSwitch(minimumLevel)); } } public class LoggerSettingsConfiguration { private readonly LoggerConfiguration _loggerConfiguration; internal LoggerSettingsConfiguration(LoggerConfiguration loggerConfiguration) { _loggerConfiguration = Guard.AgainstNull(loggerConfiguration, "loggerConfiguration"); } public LoggerConfiguration Settings(ILoggerSettings settings) { Guard.AgainstNull(settings, "settings"); settings.Configure(_loggerConfiguration); return _loggerConfiguration; } [RequiresUnreferencedCode("KeyValuePair scans for configuration assemblies at run time and is not compatible with trimming.")] [RequiresDynamicCode("KeyValuePair may need to create arrays, which requires dynamic code generation and is not compatible with AOT.")] public LoggerConfiguration KeyValuePairs(System.Collections.Generic.IEnumerable> settings) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) Guard.AgainstNull(settings, "settings"); Dictionary val = new Dictionary(); System.Collections.Generic.IEnumerator> enumerator = settings.GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { KeyValuePair current = enumerator.Current; val[current.Key] = current.Value; } } finally { ((System.IDisposable)enumerator)?.Dispose(); } return KeyValuePairs((IReadOnlyDictionary)(object)val); } [RequiresUnreferencedCode("KeyValuePair scans for configuration settings at run time.")] [RequiresDynamicCode("Creates arrays of unknown element type")] private LoggerConfiguration KeyValuePairs(IReadOnlyDictionary settings) { return Settings(new KeyValuePairSettings(settings)); } } public class LoggerSinkConfiguration { private readonly LoggerConfiguration _loggerConfiguration; private readonly Action _addSink; internal LoggerSinkConfiguration(LoggerConfiguration loggerConfiguration, Action addSink) { _loggerConfiguration = Guard.AgainstNull(loggerConfiguration, "loggerConfiguration"); _addSink = Guard.AgainstNull>(addSink, "addSink"); } [EditorBrowsable(/*Could not decode attribute arguments.*/)] public LoggerConfiguration Sink(ILogEventSink logEventSink, LogEventLevel restrictedToMinimumLevel) { return Sink(logEventSink, restrictedToMinimumLevel, null); } public LoggerConfiguration Sink(ILogEventSink logEventSink, LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose, LoggingLevelSwitch? levelSwitch = null) { Guard.AgainstNull(logEventSink, "logEventSink"); ILogEventSink logEventSink2 = logEventSink; if (levelSwitch != null) { if (restrictedToMinimumLevel != 0) { SelfLog.WriteLine("Sink {0} was configured with both a level switch and minimum level '{1}'; the minimum level will be ignored and the switch level used", logEventSink2, restrictedToMinimumLevel); } logEventSink2 = new RestrictedSink(logEventSink2, levelSwitch); } else if (restrictedToMinimumLevel > LogEventLevel.Verbose) { logEventSink2 = new RestrictedSink(logEventSink2, new LoggingLevelSwitch(restrictedToMinimumLevel)); } _addSink.Invoke(logEventSink2); return _loggerConfiguration; } public LoggerConfiguration Sink(LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose, LoggingLevelSwitch? levelSwitch = null) where TSink : ILogEventSink, new() { return Sink(new TSink(), restrictedToMinimumLevel, levelSwitch); } public LoggerConfiguration Sink(IBatchedLogEventSink batchedLogEventSink, BatchingOptions batchingOptions, LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose, LoggingLevelSwitch? levelSwitch = null) { Guard.AgainstNull(batchedLogEventSink, "batchedLogEventSink"); Guard.AgainstNull(batchingOptions, "batchingOptions"); return Sink(new BatchingSink(batchedLogEventSink, batchingOptions), restrictedToMinimumLevel, levelSwitch); } public LoggerConfiguration Sink(BatchingOptions batchingOptions, LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose, LoggingLevelSwitch? levelSwitch = null) where TSink : IBatchedLogEventSink, new() { return Sink(new TSink(), batchingOptions, restrictedToMinimumLevel, levelSwitch); } public LoggerConfiguration Logger(Action configureLogger, LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose, LoggingLevelSwitch? levelSwitch = null) { Guard.AgainstNull>(configureLogger, "configureLogger"); LoggerConfiguration loggerConfiguration = new LoggerConfiguration().MinimumLevel.Is(LogEventLevel.Verbose); configureLogger.Invoke(loggerConfiguration); Logger logger = loggerConfiguration.CreateLogger(); if (logger.HasOverrideMap) { SelfLog.WriteLine("Minimum level overrides are not supported on sub-loggers and may be removed completely in a future version."); } SecondaryLoggerSink logEventSink = new SecondaryLoggerSink(logger, attemptDispose: true); return Sink(logEventSink, restrictedToMinimumLevel, levelSwitch); } [EditorBrowsable(/*Could not decode attribute arguments.*/)] public LoggerConfiguration Logger(ILogger logger, LogEventLevel restrictedToMinimumLevel) { return Logger(logger, attemptDispose: false, restrictedToMinimumLevel); } public LoggerConfiguration Logger(ILogger logger, bool attemptDispose = false, LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose, LoggingLevelSwitch? levelSwitch = null) { Guard.AgainstNull(logger, "logger"); if (logger is Logger logger2 && logger2.HasOverrideMap) { SelfLog.WriteLine("Minimum level overrides are not supported on sub-loggers and may be removed completely in a future version."); } SecondaryLoggerSink logEventSink = new SecondaryLoggerSink(logger, attemptDispose); return Sink(logEventSink, restrictedToMinimumLevel, levelSwitch); } public LoggerConfiguration Conditional(Func condition, Action configureSink) { Func condition2 = condition; Guard.AgainstNull>(condition2, "condition"); Guard.AgainstNull>(configureSink, "configureSink"); return Sink(Wrap((ILogEventSink s) => new ConditionalSink(s, condition2), configureSink)); } [Obsolete("Use the two-argument `Wrap()` overload to construct a wrapper, then use `WriteTo.Sink()` to add it to the configuration.")] public static LoggerConfiguration Wrap(LoggerSinkConfiguration loggerSinkConfiguration, Func wrapSink, Action configureWrappedSink, LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose, LoggingLevelSwitch? levelSwitch = null) { ILogEventSink logEventSink = Wrap(wrapSink, configureWrappedSink); return loggerSinkConfiguration.Sink(logEventSink, restrictedToMinimumLevel, levelSwitch); } public static ILogEventSink Wrap(Func wrapSink, Action configureWrappedSink) { Guard.AgainstNull>(wrapSink, "wrapSink"); Guard.AgainstNull>(configureWrappedSink, "configureWrappedSink"); ILogEventSink logEventSink = CreateSink(configureWrappedSink); ILogEventSink logEventSink2 = wrapSink.Invoke(logEventSink); bool flag = !(logEventSink2 is System.IDisposable); if (flag) { bool flag2 = ((logEventSink is System.IDisposable || logEventSink is System.IAsyncDisposable) ? true : false); flag = flag2; } if (flag) { logEventSink2 = new DisposeDelegatingSink(logEventSink2, logEventSink as System.IDisposable, logEventSink as System.IAsyncDisposable); } return logEventSink2; } public static ILogEventSink CreateSink(Action configure) { Guard.AgainstNull>(configure, "configure"); List val = new List(); LoggerConfiguration loggerConfiguration = new LoggerConfiguration(); LoggerSinkConfiguration loggerSinkConfiguration2 = (loggerConfiguration.WriteTo = new LoggerSinkConfiguration(loggerConfiguration, val.Add)); configure.Invoke(loggerSinkConfiguration2); if (val.Count != 1) { return new DisposingAggregateSink((System.Collections.Generic.IEnumerable)val); } return val[0]; } } } namespace Serilog.Capturing { internal class PropertyValueConverter : ILogEventPropertyFactory, ILogEventPropertyValueFactory { private class DepthLimiter : ILogEventPropertyValueFactory { [ThreadStatic] private static int _currentDepth; private readonly int _maximumDestructuringDepth; private readonly PropertyValueConverter _propertyValueConverter; public DepthLimiter(int maximumDepth, PropertyValueConverter propertyValueConverter) { _maximumDestructuringDepth = maximumDepth; _propertyValueConverter = propertyValueConverter; } public static void SetCurrentDepth(int depth) { _currentDepth = depth; } public LogEventPropertyValue CreatePropertyValue(object? value, Destructuring destructuring) { int currentDepth = _currentDepth; LogEventPropertyValue? result = DefaultIfMaximumDepth(currentDepth) ?? _propertyValueConverter.CreatePropertyValue(value, destructuring, currentDepth + 1); _currentDepth = currentDepth; return result; } LogEventPropertyValue ILogEventPropertyValueFactory.CreatePropertyValue(object? value, bool destructureObjects) { int currentDepth = _currentDepth; LogEventPropertyValue? result = DefaultIfMaximumDepth(currentDepth) ?? _propertyValueConverter.CreatePropertyValue(value, destructureObjects, currentDepth + 1); _currentDepth = currentDepth; return result; } private LogEventPropertyValue? DefaultIfMaximumDepth(int depth) { if (depth == _maximumDestructuringDepth) { SelfLog.WriteLine("Maximum destructuring depth reached."); return ScalarValue.Null; } return null; } } [CompilerGenerated] private sealed class <g__MapToDictionaryElements|15_0>d : System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator>, System.Collections.IEnumerator, System.IDisposable { private int <>1__state; private KeyValuePair <>2__current; private int <>l__initialThreadId; private IDictionary dictionaryEntries; public IDictionary <>3__dictionaryEntries; public PropertyValueConverter <>4__this; private Destructuring destructure; public Destructuring <>3__destructure; private int 5__2; private IDictionaryEnumerator <>7__wrap2; KeyValuePair System.Collections.Generic.IEnumerator>.Current { [DebuggerHidden] get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return <>2__current; } } [DebuggerHidden] public <g__MapToDictionaryElements|15_0>d(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void System.IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } } private bool MoveNext() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) bool result; try { int num = <>1__state; PropertyValueConverter propertyValueConverter = <>4__this; switch (num) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; 5__2 = 0; <>7__wrap2 = dictionaryEntries.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; } KeyValuePair val2 = default(KeyValuePair); while (true) { if (((System.Collections.IEnumerator)<>7__wrap2).MoveNext()) { DictionaryEntry val = (DictionaryEntry)((System.Collections.IEnumerator)<>7__wrap2).Current; if (++5__2 > propertyValueConverter._maximumCollectionCount) { result = false; <>m__Finally1(); break; } val2..ctor((ScalarValue)propertyValueConverter._depthLimiter.CreatePropertyValue(((DictionaryEntry)(ref val)).Key, destructure), propertyValueConverter._depthLimiter.CreatePropertyValue(((DictionaryEntry)(ref val)).Value, destructure)); if (val2.Key.Value != null) { <>2__current = val2; <>1__state = 1; result = true; break; } continue; } <>m__Finally1(); <>7__wrap2 = null; result = false; break; } end_IL_0000:; } catch { //try-fault ((System.IDisposable)this).Dispose(); throw; } return result; } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap2 is System.IDisposable disposable) { disposable.Dispose(); } } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] System.Collections.Generic.IEnumerator> System.Collections.Generic.IEnumerable>.GetEnumerator() { <g__MapToDictionaryElements|15_0>d <g__MapToDictionaryElements|15_0>d; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <g__MapToDictionaryElements|15_0>d = this; } else { <g__MapToDictionaryElements|15_0>d = new <g__MapToDictionaryElements|15_0>d(0) { <>4__this = <>4__this }; } <g__MapToDictionaryElements|15_0>d.dictionaryEntries = <>3__dictionaryEntries; <g__MapToDictionaryElements|15_0>d.destructure = <>3__destructure; return <g__MapToDictionaryElements|15_0>d; } [DebuggerHidden] System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable>)this).GetEnumerator(); } } [CompilerGenerated] private sealed class <g__MapToSequenceElements|15_1>d : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator, System.Collections.IEnumerator, System.IDisposable { private int <>1__state; private LogEventPropertyValue <>2__current; private int <>l__initialThreadId; private System.Collections.IEnumerable sequence; public System.Collections.IEnumerable <>3__sequence; public PropertyValueConverter <>4__this; private Destructuring destructure; public Destructuring <>3__destructure; private int 5__2; private System.Collections.IEnumerator <>7__wrap2; LogEventPropertyValue System.Collections.Generic.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <g__MapToSequenceElements|15_1>d(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void System.IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } } private bool MoveNext() { bool result; try { int num = <>1__state; PropertyValueConverter propertyValueConverter = <>4__this; switch (num) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; 5__2 = 0; <>7__wrap2 = sequence.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; } if (<>7__wrap2.MoveNext()) { object current = <>7__wrap2.Current; if (++5__2 > propertyValueConverter._maximumCollectionCount) { result = false; <>m__Finally1(); } else { <>2__current = propertyValueConverter._depthLimiter.CreatePropertyValue(current, destructure); <>1__state = 1; result = true; } } else { <>m__Finally1(); <>7__wrap2 = null; result = false; } end_IL_0000:; } catch { //try-fault ((System.IDisposable)this).Dispose(); throw; } return result; } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap2 is System.IDisposable disposable) { disposable.Dispose(); } } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { <g__MapToSequenceElements|15_1>d <g__MapToSequenceElements|15_1>d; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <g__MapToSequenceElements|15_1>d = this; } else { <g__MapToSequenceElements|15_1>d = new <g__MapToSequenceElements|15_1>d(0) { <>4__this = <>4__this }; } <g__MapToSequenceElements|15_1>d.sequence = <>3__sequence; <g__MapToSequenceElements|15_1>d.destructure = <>3__destructure; return <g__MapToSequenceElements|15_1>d; } [DebuggerHidden] System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable)this).GetEnumerator(); } } [CompilerGenerated] private sealed class d__22 : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator, System.Collections.IEnumerator, System.IDisposable { private int <>1__state; private LogEventProperty <>2__current; private int <>l__initialThreadId; private System.Type type; public System.Type <>3__type; private object value; public object <>3__value; public PropertyValueConverter <>4__this; private System.Collections.Generic.IEnumerator <>7__wrap1; LogEventProperty System.Collections.Generic.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__22(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void System.IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } } private bool MoveNext() { //IL_007a: Expected O, but got Unknown try { int num = <>1__state; PropertyValueConverter propertyValueConverter = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = type.GetPropertiesRecursive().GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; } while (((System.Collections.IEnumerator)<>7__wrap1).MoveNext()) { PropertyInfo current = <>7__wrap1.Current; object obj; try { obj = current.GetValue(value); } catch (TargetParameterCountException) { SelfLog.WriteLine("The property accessor {0} is a non-default indexer", current); continue; } catch (TargetInvocationException val2) { TargetInvocationException val3 = val2; SelfLog.WriteLine("The property accessor {0} threw exception: {1}", current, val3); if (propertyValueConverter._propagateExceptions) { throw; } System.Exception innerException = ((System.Exception)(object)val3).InnerException; obj = "The property accessor threw an exception: " + ((innerException != null) ? ((MemberInfo)innerException.GetType()).Name : null); } catch (NotSupportedException) { SelfLog.WriteLine("The property accessor {0} is not supported via Reflection API", current); if (propertyValueConverter._propagateExceptions) { throw; } obj = "Accessing this property is not supported via Reflection API"; } <>2__current = new LogEventProperty(((MemberInfo)current).Name, propertyValueConverter._depthLimiter.CreatePropertyValue(obj, Destructuring.Destructure)); <>1__state = 1; return true; } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((System.IDisposable)this).Dispose(); throw; } } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { ((System.IDisposable)<>7__wrap1).Dispose(); } } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { d__22 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__22(0) { <>4__this = <>4__this }; } d__.value = <>3__value; d__.type = <>3__type; return d__; } [DebuggerHidden] System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable)this).GetEnumerator(); } } private static readonly HashSet BuiltInScalarTypes; private readonly IDestructuringPolicy[] _destructuringPolicies; private readonly System.Type[] _dictionaryTypes; private readonly IScalarConversionPolicy[] _scalarConversionPolicies; private readonly DepthLimiter _depthLimiter; private readonly int _maximumStringLength; private readonly int _maximumCollectionCount; private readonly bool _propagateExceptions; public PropertyValueConverter(int maximumDestructuringDepth, int maximumStringLength, int maximumCollectionCount, System.Collections.Generic.IEnumerable additionalScalarTypes, System.Collections.Generic.IEnumerable additionalDictionaryTypes, System.Collections.Generic.IEnumerable additionalDestructuringPolicies, bool propagateExceptions) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) Guard.AgainstNull(additionalScalarTypes, "additionalScalarTypes"); Guard.AgainstNull(additionalDestructuringPolicies, "additionalDestructuringPolicies"); if (maximumDestructuringDepth < 0) { throw new ArgumentOutOfRangeException("maximumDestructuringDepth"); } if (maximumStringLength < 2) { throw new ArgumentOutOfRangeException("maximumStringLength"); } if (maximumCollectionCount < 1) { throw new ArgumentOutOfRangeException("maximumCollectionCount"); } _propagateExceptions = propagateExceptions; _maximumStringLength = maximumStringLength; _maximumCollectionCount = maximumCollectionCount; _scalarConversionPolicies = new IScalarConversionPolicy[5] { new PrimitiveScalarConversionPolicy(), new SimpleScalarConversionPolicy(Enumerable.Concat((System.Collections.Generic.IEnumerable)BuiltInScalarTypes, additionalScalarTypes)), new EnumScalarConversionPolicy(), new ByteArrayScalarConversionPolicy(), new ByteMemoryScalarConversionPolicy() }; _destructuringPolicies = Enumerable.ToArray(Enumerable.Concat(additionalDestructuringPolicies, (System.Collections.Generic.IEnumerable)new IDestructuringPolicy[2] { new DelegateDestructuringPolicy(), new ReflectionTypesScalarDestructuringPolicy() })); _dictionaryTypes = Enumerable.ToArray(additionalDictionaryTypes); _depthLimiter = new DepthLimiter(maximumDestructuringDepth, this); } public LogEventProperty CreateProperty(string name, object? value, bool destructureObjects = false) { return new LogEventProperty(name, CreatePropertyValue(value, destructureObjects)); } public LogEventPropertyValue CreatePropertyValue(object? value, bool destructureObjects = false) { return CreatePropertyValue(value, destructureObjects, 1); } public LogEventPropertyValue CreatePropertyValue(object? value, Destructuring destructuring) { try { return CreatePropertyValue(value, destructuring, 1); } catch (System.Exception ex) { SelfLog.WriteLine("Exception caught while converting property value: {0}", ex); if (_propagateExceptions) { throw; } return new ScalarValue("Capturing the property value threw an exception: " + ((MemberInfo)ex.GetType()).Name); } } private LogEventPropertyValue CreatePropertyValue(object? value, bool destructureObjects, int depth) { return CreatePropertyValue(value, destructureObjects ? Destructuring.Destructure : Destructuring.Default, depth); } private LogEventPropertyValue CreatePropertyValue(object? value, Destructuring destructuring, int depth) { if (value == null) { return ScalarValue.Null; } switch (destructuring) { case Destructuring.Stringify: return Stringify(value); case Destructuring.Destructure: if (value is string text) { value = TruncateIfNecessary(text); } break; } if (value is string) { return new ScalarValue(value); } IScalarConversionPolicy[] scalarConversionPolicies = _scalarConversionPolicies; for (int i = 0; i < scalarConversionPolicies.Length; i++) { if (scalarConversionPolicies[i].TryConvertToScalar(value, out ScalarValue result)) { return result; } } DepthLimiter.SetCurrentDepth(depth); if (destructuring == Destructuring.Destructure) { IDestructuringPolicy[] destructuringPolicies = _destructuringPolicies; for (int i = 0; i < destructuringPolicies.Length; i++) { if (destructuringPolicies[i].TryDestructure(value, _depthLimiter, out LogEventPropertyValue result2)) { return result2; } } } System.Type type = value.GetType(); if (TryConvertEnumerable(value, type, destructuring, out LogEventPropertyValue result3)) { return result3; } if (TryConvertValueTuple(value, type, destructuring, out LogEventPropertyValue result4)) { return result4; } if (TrimConfiguration.IsCompilerGeneratedCodeSupported && TryConvertCompilerGeneratedType(value, type, destructuring, out LogEventPropertyValue result5)) { return result5; } return new ScalarValue(value.ToString() ?? ""); } private bool TryConvertEnumerable(object value, System.Type type, Destructuring destructuring, [NotNullWhen(true)] out LogEventPropertyValue? result) { if (value is System.Collections.IEnumerable enumerable) { if (TryGetDictionary(value, type, out IDictionary dictionary)) { result = new DictionaryValue(MapToDictionaryElements(dictionary, destructuring)); return true; } if (enumerable is System.Collections.IList list && ((System.Collections.ICollection)list).Count <= _maximumCollectionCount) { if (((System.Collections.ICollection)list).Count == 0) { result = SequenceValue.Empty; } else { LogEventPropertyValue[] array = new LogEventPropertyValue[((System.Collections.ICollection)list).Count]; for (int i = 0; i < ((System.Collections.ICollection)list).Count; i++) { array[i] = _depthLimiter.CreatePropertyValue(list[i], destructuring); } result = new SequenceValue(array); } } else { result = new SequenceValue(MapToSequenceElements(enumerable, destructuring)); } return true; } result = null; return false; [IteratorStateMachine(typeof(<g__MapToDictionaryElements|15_0>d))] [CompilerGenerated] System.Collections.Generic.IEnumerable> MapToDictionaryElements(IDictionary dictionaryEntries, Destructuring destructure) { int count2 = 0; IDictionaryEnumerator enumerator2 = dictionaryEntries.GetEnumerator(); try { KeyValuePair val2 = default(KeyValuePair); while (((System.Collections.IEnumerator)enumerator2).MoveNext()) { DictionaryEntry val = (DictionaryEntry)((System.Collections.IEnumerator)enumerator2).Current; int num2 = count2 + 1; count2 = num2; if (num2 > _maximumCollectionCount) { yield break; } val2..ctor((ScalarValue)_depthLimiter.CreatePropertyValue(((DictionaryEntry)(ref val)).Key, destructure), _depthLimiter.CreatePropertyValue(((DictionaryEntry)(ref val)).Value, destructure)); if (val2.Key.Value != null) { yield return val2; } } } finally { if (enumerator2 is System.IDisposable disposable) { disposable.Dispose(); } } } [IteratorStateMachine(typeof(<g__MapToSequenceElements|15_1>d))] [CompilerGenerated] System.Collections.Generic.IEnumerable MapToSequenceElements(System.Collections.IEnumerable sequence, Destructuring destructure) { int count = 0; foreach (object item in sequence) { int num = count + 1; count = num; if (num > _maximumCollectionCount) { yield break; } yield return _depthLimiter.CreatePropertyValue(item, destructure); } } } private bool TryConvertValueTuple(object value, System.Type type, Destructuring destructuring, [NotNullWhen(true)] out LogEventPropertyValue? result) { ITuple val = (ITuple)((value is ITuple) ? value : null); if (val == null) { result = null; return false; } LogEventPropertyValue[] array = new LogEventPropertyValue[val.Length]; for (int i = 0; i < val.Length; i++) { object value2 = val[i]; array[i] = _depthLimiter.CreatePropertyValue(value2, destructuring); } result = new SequenceValue(array); return true; } private bool TryConvertCompilerGeneratedType(object value, [DynamicallyAccessedMembers(/*Could not decode attribute arguments.*/)] System.Type type, Destructuring destructuring, [NotNullWhen(true)] out LogEventPropertyValue? result) { if (destructuring == Destructuring.Destructure) { string text = ((MemberInfo)type).Name; if (text.Length <= 0 || IsCompilerGeneratedType(type)) { text = null; } result = new StructureValue(GetProperties(value, type), text); return true; } result = null; return false; } private LogEventPropertyValue Stringify(object value) { string text = value.ToString(); return new ScalarValue((text == null) ? "" : TruncateIfNecessary(text)); } private string TruncateIfNecessary(string text) { if (text.Length > _maximumStringLength) { return text.Substring(0, _maximumStringLength - 1) + "…"; } return text; } private bool TryGetDictionary(object value, System.Type valueType, [NotNullWhen(true)] out IDictionary? dictionary) { IDictionary val = (IDictionary)((value is IDictionary) ? value : null); if (val != null) { if (Enumerable.Contains((System.Collections.Generic.IEnumerable)_dictionaryTypes, valueType)) { dictionary = val; return true; } if (valueType.IsConstructedGenericType) { System.Type genericTypeDefinition = valueType.GetGenericTypeDefinition(); if ((genericTypeDefinition == typeof(Dictionary<, >) || genericTypeDefinition == typeof(ReadOnlyDictionary<, >)) && IsValidDictionaryKeyType(valueType.GenericTypeArguments[0])) { dictionary = val; return true; } } } dictionary = null; return false; } private static bool IsValidDictionaryKeyType(System.Type valueType) { if (!valueType.IsPrimitive && !BuiltInScalarTypes.Contains(valueType)) { return valueType.IsEnum; } return true; } [IteratorStateMachine(typeof(d__22))] private System.Collections.Generic.IEnumerable GetProperties(object value, [DynamicallyAccessedMembers(/*Could not decode attribute arguments.*/)] System.Type type) { System.Collections.Generic.IEnumerator enumerator = type.GetPropertiesRecursive().GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { PropertyInfo current = enumerator.Current; object value2; try { value2 = current.GetValue(value); } catch (TargetParameterCountException) { SelfLog.WriteLine("The property accessor {0} is a non-default indexer", current); continue; } catch (TargetInvocationException val2) { TargetInvocationException val3 = val2; SelfLog.WriteLine("The property accessor {0} threw exception: {1}", current, val3); if (_propagateExceptions) { throw; } System.Exception innerException = ((System.Exception)(object)val3).InnerException; value2 = "The property accessor threw an exception: " + ((innerException != null) ? ((MemberInfo)innerException.GetType()).Name : null); } catch (NotSupportedException) { SelfLog.WriteLine("The property accessor {0} is not supported via Reflection API", current); if (_propagateExceptions) { throw; } value2 = "Accessing this property is not supported via Reflection API"; } yield return new LogEventProperty(((MemberInfo)current).Name, _depthLimiter.CreatePropertyValue(value2, Destructuring.Destructure)); } } finally { ((System.IDisposable)enumerator)?.Dispose(); } } [MethodImpl(256)] private static bool IsCompilerGeneratedType(System.Type type) { if (!type.IsGenericType || !type.IsSealed || type.Namespace != null) { return false; } string name = ((MemberInfo)type).Name; if (name[0] != '<') { if (name.Length > 2 && name[0] == 'V' && name[1] == 'B') { return name[2] == '$'; } return false; } return true; } static PropertyValueConverter() { HashSet obj = new HashSet(); obj.Add(typeof(decimal)); obj.Add(typeof(string)); obj.Add(typeof(System.DateTime)); obj.Add(typeof(DateTimeOffset)); obj.Add(typeof(TimeSpan)); obj.Add(typeof(Guid)); obj.Add(typeof(Uri)); obj.Add(typeof(TimeOnly)); obj.Add(typeof(DateOnly)); BuiltInScalarTypes = obj; } } internal static class GetablePropertyFinder { [CompilerGenerated] private sealed class d__0 : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator, System.Collections.IEnumerator, System.IDisposable { private int <>1__state; private PropertyInfo <>2__current; private int <>l__initialThreadId; private System.Type type; public System.Type <>3__type; private HashSet 5__2; private PropertyInfo[] <>7__wrap2; private int <>7__wrap3; PropertyInfo System.Collections.Generic.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void System.IDisposable.Dispose() { } private bool MoveNext() { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; goto IL_00ae; } <>1__state = -1; 5__2 = new HashSet(); <>7__wrap2 = type.GetProperties((BindingFlags)84); <>7__wrap3 = 0; goto IL_00bc; IL_00ae: <>7__wrap3++; goto IL_00bc; IL_00bc: if (<>7__wrap3 < <>7__wrap2.Length) { PropertyInfo val = <>7__wrap2[<>7__wrap3]; if (val.CanRead && !5__2.Contains(((MemberInfo)val).Name) && (!(((MemberInfo)val).Name == "Item") || val.GetIndexParameters().Length == 0)) { 5__2.Add(((MemberInfo)val).Name); <>2__current = val; <>1__state = 1; return true; } goto IL_00ae; } <>7__wrap2 = null; return false; } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { d__0 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__0(0); } d__.type = <>3__type; return d__; } [DebuggerHidden] System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable)this).GetEnumerator(); } } [IteratorStateMachine(typeof(d__0))] internal static System.Collections.Generic.IEnumerable GetPropertiesRecursive([DynamicallyAccessedMembers(/*Could not decode attribute arguments.*/)] this System.Type type) { HashSet seenNames = new HashSet(); PropertyInfo[] properties = type.GetProperties((BindingFlags)84); foreach (PropertyInfo val in properties) { if (val.CanRead && !seenNames.Contains(((MemberInfo)val).Name) && (!(((MemberInfo)val).Name == "Item") || val.GetIndexParameters().Length == 0)) { seenNames.Add(((MemberInfo)val).Name); yield return val; } } } } internal class MessageTemplateProcessor : ILogEventPropertyFactory, ILogEventPropertyValueFactory { private readonly MessageTemplateCache _parser = new MessageTemplateCache(new MessageTemplateParser()); private readonly PropertyBinder _propertyBinder; private readonly PropertyValueConverter _propertyValueConverter; public MessageTemplateProcessor(PropertyValueConverter propertyValueConverter) { _propertyValueConverter = propertyValueConverter; _propertyBinder = new PropertyBinder(_propertyValueConverter); } public void Process(string messageTemplate, System.ReadOnlySpan messageTemplateParameters, out MessageTemplate parsedTemplate, out EventProperty[] properties) { parsedTemplate = _parser.Parse(messageTemplate); properties = _propertyBinder.ConstructProperties(parsedTemplate, messageTemplateParameters); } public LogEventProperty CreateProperty(string name, object? value, bool destructureObjects = false) { return _propertyValueConverter.CreateProperty(name, value, destructureObjects); } public LogEventPropertyValue CreatePropertyValue(object? value, bool destructureObjects = false) { return _propertyValueConverter.CreatePropertyValue(value, destructureObjects); } } internal class PropertyBinder { private readonly PropertyValueConverter _valueConverter; private static readonly EventProperty[] NoProperties = System.Array.Empty(); public PropertyBinder(PropertyValueConverter valueConverter) { _valueConverter = valueConverter; } public EventProperty[] ConstructProperties(MessageTemplate messageTemplate, System.ReadOnlySpan messageTemplateParameters) { if (messageTemplateParameters.Length == 0) { if (messageTemplate.NamedProperties != null || messageTemplate.PositionalProperties != null) { SelfLog.WriteLine("Required properties not provided for: {0}", messageTemplate); } return NoProperties; } if (messageTemplate.PositionalProperties != null) { return ConstructPositionalProperties(messageTemplate, messageTemplateParameters, messageTemplate.PositionalProperties); } return ConstructNamedProperties(messageTemplate, messageTemplateParameters); } private unsafe EventProperty[] ConstructPositionalProperties(MessageTemplate template, System.ReadOnlySpan messageTemplateParameters, PropertyToken[] positionalProperties) { EventProperty[] array = new EventProperty[messageTemplateParameters.Length]; foreach (PropertyToken propertyToken in positionalProperties) { if (propertyToken.TryGetPositionalValue(out var position)) { if (position < 0 || position >= messageTemplateParameters.Length) { SelfLog.WriteLine("Unassigned positional value {0} in: {1}", position, template); } else { array[position] = ConstructProperty(propertyToken, System.Runtime.CompilerServices.Unsafe.Read((void*)messageTemplateParameters[position])); } } } int num = 0; for (int j = 0; j < array.Length; j++) { if (!array[j].Equals(EventProperty.None)) { array[num] = array[j]; num++; } } if (array.Length != messageTemplateParameters.Length) { SelfLog.WriteLine("Positional property count does not match parameter count: {0}", template); } if (num != array.Length) { System.Array.Resize(ref array, num); } return array; } private unsafe EventProperty[] ConstructNamedProperties(MessageTemplate template, System.ReadOnlySpan messageTemplateParameters) { PropertyToken[] namedProperties = template.NamedProperties; if (namedProperties == null) { return NoProperties; } int num = namedProperties.Length; if (namedProperties.Length != messageTemplateParameters.Length) { num = Math.Min(namedProperties.Length, messageTemplateParameters.Length); SelfLog.WriteLine("Named property count does not match parameter count: {0}", template); } EventProperty[] array = new EventProperty[messageTemplateParameters.Length]; for (int i = 0; i < num; i++) { PropertyToken propertyToken = namedProperties[i]; object value = System.Runtime.CompilerServices.Unsafe.Read((void*)messageTemplateParameters[i]); array[i] = ConstructProperty(propertyToken, value); } for (int j = num; j < messageTemplateParameters.Length; j++) { LogEventPropertyValue value2 = _valueConverter.CreatePropertyValue(System.Runtime.CompilerServices.Unsafe.Read((void*)messageTemplateParameters[j])); array[j] = new EventProperty("__" + j, value2); } return array; } private EventProperty ConstructProperty(PropertyToken propertyToken, object? value) { return new EventProperty(propertyToken.PropertyName, _valueConverter.CreatePropertyValue(value, propertyToken.Destructuring)); } } internal static class TrimConfiguration { [field: CompilerGenerated] public static bool IsCompilerGeneratedCodeSupported { [CompilerGenerated] get; } static TrimConfiguration() { bool flag = default(bool); IsCompilerGeneratedCodeSupported = !AppContext.TryGetSwitch("Serilog.Capturing.IsCompilerGeneratedCodeSupported", ref flag) || flag; } } }