aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-06-06 21:59:20 -0500
committerGitHub <noreply@github.com>2022-06-06 21:59:20 -0500
commit83391ed8a632aa362db837dd41ea7b945e829741 (patch)
treef4efddf9bc5ab93e3810e506295175e325f58ee0
parent25033d9f61b442d974d4628d97d1c823e15c7769 (diff)
parent2fbdac00ccf67c6032552f8a3a387be55ca29323 (diff)
downloadslskd-83391ed8a632aa362db837dd41ea7b945e829741.tar.gz
Merge pull request #503 from slskd/distributed-logging
Allow distributed network logging to be disabled (and disable it by default)
-rw-r--r--config/slskd.example.yml1
-rw-r--r--docs/config.md1
-rw-r--r--src/slskd/Application.cs9
-rw-r--r--src/slskd/Options.cs8
4 files changed, 18 insertions, 1 deletions
diff --git a/config/slskd.example.yml b/config/slskd.example.yml
index fbf0371e..492d5f0e 100644
--- a/config/slskd.example.yml
+++ b/config/slskd.example.yml
@@ -82,6 +82,7 @@
# disabled: false
# disable_children: false
# child_limit: 25
+# logging: false
# connection:
# timeout:
# connect: 10000
diff --git a/docs/config.md b/docs/config.md
index 605b159b..a3fde410 100644
--- a/docs/config.md
+++ b/docs/config.md
@@ -322,6 +322,7 @@ Changing these values may require the server connection to be reset, depending o
| `--slsk-no-dnet` | `SLSK_NO_DNET` | Determines whether the distributed network is disabled. If disabled, the client will not obtain a parent or any child connections, and will not receive distributed search requests. |
| `--slsk-dnet-no-children` | `SLSK_DNET_NO_CHILDREN` | Determines whether to disallow distributed children |
| `--slsk-dnet-children` | `SLSK_DNET_CHILDREN` | The maximum number of distributed children to accept |
+| `--slsk-dnet-logging` | `SLSK_DNET_LOGGING` | Determines whether to enable distributed network logging
#### **YAML**
```yaml
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);
}
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;
+
+ /// <summary>
+ /// Gets a value indicating whether distributed network logging should be enabled.
+ /// </summary>
+ [Argument(default, "slsk-dnet-logging")]
+ [EnvironmentVariable("SLSK_DNET_LOGGING")]
+ [Description("enable distributed network logging")]
+ public bool Logging { get; init; } = false;
}
}