diff options
| author | JP Dillingham <jp@dillingham.me> | 2024-06-18 07:51:28 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-18 07:51:28 -0500 |
| commit | a6411b4b5e9d2ff0718d09a88cfd10903716292c (patch) | |
| tree | 5a9fc027f35af593fb5c1168bfbeaeec24acdaf3 /src | |
| parent | 2c45386bfa4ad1a8a9dd5cf5793ee895ec0aeeaa (diff) | |
| parent | 6d8aa0fcb9cbfe22309139fe9e8b9f86027352e8 (diff) | |
| download | slskd-a6411b4b5e9d2ff0718d09a88cfd10903716292c.tar.gz | |
Merge pull request #1137 from zliebersbach/feat/config-console-log-colour
Add option to disable console log colours
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Core/Options.cs | 9 | ||||
| -rw-r--r-- | src/slskd/Program.cs | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 05174031..8aa915fc 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -1294,6 +1294,15 @@ namespace slskd [Description("enable logging to disk")] [RequiresRestart] public bool Disk { get; init; } = false; + + /// <summary> + /// Gets a value indicating whether console logs should be colorized. + /// </summary> + [Argument(default, "no-color")] + [EnvironmentVariable("NO_COLOR")] + [Description("disable console log colors")] + [RequiresRestart] + public bool Color { get; init; } = true; } /// <summary> diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 81554b62..deae45e8 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -52,6 +52,7 @@ namespace slskd using Serilog; using Serilog.Events; using Serilog.Sinks.Grafana.Loki; + using Serilog.Sinks.SystemConsole.Themes; using slskd.Authentication; using slskd.Configuration; using slskd.Core.API; @@ -973,6 +974,7 @@ namespace slskd .Enrich.WithProperty("ProcessId", ProcessId) .Enrich.FromLogContext() .WriteTo.Console( + theme: OptionsAtStartup.Logger.Color ? SystemConsoleTheme.Literate : ConsoleTheme.None, outputTemplate: (OptionsAtStartup.Debug ? "[{SourceContext}] " : string.Empty) + "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}") .WriteTo.Async(config => config.Conditional( |
