diff --git a/docs/config/discords.md b/docs/config/discords.md index fd28627e..eb9c1b1b 100644 --- a/docs/config/discords.md +++ b/docs/config/discords.md @@ -130,6 +130,8 @@ Copy your Discord specific configs to the `bin/discords` folder and reference th } }, // Icon style for postings from Discord server. - "iconStyle": "Default" + "iconStyle": "Default", + // Discord client log level, only change if debugging an issue with Discord (default: 4 aka Error) + "logLevel": 4 } ``` \ No newline at end of file diff --git a/examples/discords/discord1.example.json b/examples/discords/discord1.example.json index 56b927a3..0e1cb547 100644 --- a/examples/discords/discord1.example.json +++ b/examples/discords/discord1.example.json @@ -67,5 +67,6 @@ "channelId": 0 } }, - "iconStyle": "Default" + "iconStyle": "Default", + "logLevel": 4 } diff --git a/examples/discords/discord2.example.json b/examples/discords/discord2.example.json index 0a1d308d..1eb2df27 100644 --- a/examples/discords/discord2.example.json +++ b/examples/discords/discord2.example.json @@ -67,5 +67,6 @@ "channelId": 0 } }, - "iconStyle": "Default" + "iconStyle": "Default", + "logLevel": 4 } diff --git a/src/Configuration/DiscordServerConfig.cs b/src/Configuration/DiscordServerConfig.cs index e8cfdb7d..02153baf 100644 --- a/src/Configuration/DiscordServerConfig.cs +++ b/src/Configuration/DiscordServerConfig.cs @@ -6,6 +6,8 @@ using System.Linq; using System.Text.Json.Serialization; + using Microsoft.Extensions.Logging; + using WhMgr.Services.Geofence; /// @@ -94,12 +96,19 @@ public class DiscordServerConfig [JsonPropertyName("iconStyle")] public string IconStyle { get; set; } = "Default"; + /// + /// Gets or sets the DiscordClient minimum log level to use for the DSharpPlus + /// internal logger (separate from the main logs) + /// + public LogLevel LogLevel { get; set; } + /// /// Instantiate a new class /// public DiscordServerConfig() { //Locale = "en"; + LogLevel = LogLevel.Error; } public void LoadGeofences() diff --git a/src/Services/Discord/DiscordClientFactory.cs b/src/Services/Discord/DiscordClientFactory.cs index 460294da..2071e080 100644 --- a/src/Services/Discord/DiscordClientFactory.cs +++ b/src/Services/Discord/DiscordClientFactory.cs @@ -27,10 +27,11 @@ public static DiscordClient CreateDiscordClient(DiscordServerConfig config, ISer { AutoReconnect = true, AlwaysCacheMembers = true, + // REVIEW: Hmm maybe we should compress the whole stream instead of just payload. GatewayCompressionLevel = GatewayCompressionLevel.Payload, Token = config.Bot?.Token, TokenType = TokenType.Bot, - MinimumLogLevel = Microsoft.Extensions.Logging.LogLevel.Error, + MinimumLogLevel = config.LogLevel, Intents = DiscordIntents.DirectMessages | DiscordIntents.DirectMessageTyping | DiscordIntents.GuildEmojis