diff options
Diffstat (limited to 'src/main.lib/Services/LogService.cs')
-rw-r--r-- | src/main.lib/Services/LogService.cs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/main.lib/Services/LogService.cs b/src/main.lib/Services/LogService.cs index c629a29..3b6fde5 100644 --- a/src/main.lib/Services/LogService.cs +++ b/src/main.lib/Services/LogService.cs @@ -6,6 +6,7 @@ using Serilog.Sinks.SystemConsole.Themes; using System; using System.Diagnostics; using System.IO; +using System.Runtime.InteropServices; namespace PKISharp.WACS.Services { @@ -32,17 +33,27 @@ namespace PKISharp.WACS.Services _levelSwitch = new LoggingLevelSwitch(initialMinimumLevel: initialLevel); try { + var theme = + RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && + Environment.OSVersion.Version.Major == 10 ? + (ConsoleTheme)AnsiConsoleTheme.Code : + SystemConsoleTheme.Literate; + _screenLogger = new LoggerConfiguration() .MinimumLevel.ControlledBy(_levelSwitch) .Enrich.FromLogContext() .Filter.ByIncludingOnly(x => { Dirty = true; return true; }) - .WriteTo.Console(outputTemplate: " {Message:l}{NewLine}", theme: AnsiConsoleTheme.Code) + .WriteTo.Console( + outputTemplate: " {Message:l}{NewLine}", + theme: theme) .CreateLogger(); _debugScreenLogger = new LoggerConfiguration() .MinimumLevel.ControlledBy(_levelSwitch) .Enrich.FromLogContext() .Filter.ByIncludingOnly(x => { Dirty = true; return true; }) - .WriteTo.Console(outputTemplate: " [{Level:u4}] {Message:l}{NewLine}{Exception}", theme: AnsiConsoleTheme.Code) + .WriteTo.Console( + outputTemplate: " [{Level:u4}] {Message:l}{NewLine}{Exception}", + theme: theme) .CreateLogger(); } catch (Exception ex) @@ -121,9 +132,9 @@ namespace PKISharp.WACS.Services Verbose("Verbose mode logging enabled"); } - public void Verbose(string message, params object?[] items) => Verbose(LogType.Screen, message, items); + public void Verbose(string message, params object?[] items) => Verbose(LogType.Screen | LogType.Disk, message, items); - public void Debug(string message, params object?[] items) => Debug(LogType.Screen, message, items); + public void Debug(string message, params object?[] items) => Debug(LogType.Screen | LogType.Disk, message, items); public void Warning(string message, params object?[] items) => Warning(LogType.All, message, items); @@ -131,7 +142,7 @@ namespace PKISharp.WACS.Services public void Error(Exception ex, string message, params object?[] items) => Error(LogType.All, ex, message, items); - public void Information(string message, params object?[] items) => Information(LogType.Screen, message, items); + public void Information(string message, params object?[] items) => Information(LogType.Screen | LogType.Disk, message, items); public void Information(LogType logType, string message, params object?[] items) => _Information(logType, message, items); |