From bf5d35a75d676f9004dfe6da4d3ca8a2b532a4f6 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 6 Jun 2022 20:57:50 -0500 Subject: add distributed logging flag --- src/slskd/Options.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index a8c3380c..041824de 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -924,6 +924,14 @@ namespace slskd [Description("max number of distributed children")] [Range(1, int.MaxValue)] public int ChildLimit { get; init; } = 25; + + /// + /// Gets a value indicating whether distributed network logging should be enabled. + /// + [Argument(default, "slsk-dnet-logging")] + [EnvironmentVariable("SLSK_DNET_LOGGING")] + [Description("enable distributed network logging")] + public bool Logging { get; init; } = false; } } -- cgit v1.2.3 From 1e477e18894999de2f2f39cde8336b31851fb242 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 6 Jun 2022 21:38:26 -0500 Subject: suppress logging of distributed messages if option is unset --- src/slskd/Application.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 0144daa2..3e30c029 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -366,7 +366,14 @@ namespace slskd _ => default, }; - var logger = Loggers.GetOrAdd(sender.GetType().FullName, Log.ForContext("Context", "Soulseek").ForContext("SubContext", sender.GetType().FullName)); + var source = sender.GetType().FullName; + + if (source.EndsWith("DistributedConnectionManager") && !Options.Soulseek.DistributedNetwork.Logging) + { + return; + } + + var logger = Loggers.GetOrAdd(source, Log.ForContext("Context", "Soulseek").ForContext("SubContext", source)); logger.Write(TranslateLogLevel(args.Level), "{@Message}", args.Message); } -- cgit v1.2.3