make efcore debugging a setting

This commit is contained in:
13xforever
2025-03-15 17:57:25 +05:00
parent e18aa3a556
commit 0ea16cc797
4 changed files with 13 additions and 15 deletions

View File

@@ -42,6 +42,7 @@ internal static class Config
// these settings could be configured either through `$ dotnet user-secrets`, or through environment variables (e.g. launchSettings.json, etc)
public static string CommandPrefix => config.GetValue(nameof(CommandPrefix), "!");
public static string AutoRemoveCommandPrefix => config.GetValue(nameof(AutoRemoveCommandPrefix), ".");
public static ulong BotGuildId => config.GetValue(nameof(BotGuildId), 272035812277878785ul); // discord server where the bot is supposed to be
public static ulong BotGeneralChannelId => config.GetValue(nameof(BotGeneralChannelId), 272035812277878785ul);// #rpcs3; main or general channel where noobs come first thing
public static ulong BotChannelId => config.GetValue(nameof(BotChannelId), 291679908067803136ul); // #build-updates; this is used for new build announcements
@@ -73,6 +74,7 @@ internal static class Config
public static int ChannelMessageHistorySize => config.GetValue(nameof(ChannelMessageHistorySize), 100);
public static int FunMultiplier => config.GetValue(nameof(FunMultiplier), 1);
public static int MaxPositionsForHwSurveyResults => config.GetValue(nameof(MaxPositionsForHwSurveyResults), 10);
public static string Token => config.GetValue(nameof(Token), "");
public static string AzureDevOpsToken => config.GetValue(nameof(AzureDevOpsToken), "");
public static string AzureComputerVisionKey => config.GetValue(nameof(AzureComputerVisionKey), "");
@@ -84,13 +86,12 @@ internal static class Config
public static string PreferredFontFamily => config.GetValue(nameof(PreferredFontFamily), "");
public static string LogPath => config.GetValue(nameof(LogPath), "./logs/"); // paths are relative to the working directory
public static string IrdCachePath => config.GetValue(nameof(IrdCachePath), "./ird/");
public static string RenameNameSuffix => config.GetValue(nameof(RenameNameSuffix), " (Rule 7)");
public static double GameTitleMatchThreshold => config.GetValue(nameof(GameTitleMatchThreshold), 0.57);
public static byte[] CryptoSalt => Convert.FromBase64String(config.GetValue(nameof(CryptoSalt), ""));
public static string RenameNameSuffix => config.GetValue(nameof(RenameNameSuffix), " (Rule 7)");
public static string ImgSrcNotInPublic => config.GetValue(nameof(ImgSrcNotInPublic), "https://cdn.discordapp.com/attachments/1207384388602560562/1344880816886517810/24qx11.jpg");
public static string ImgSrcNoCompatAbuse => config.GetValue(nameof(ImgSrcNoCompatAbuse), "https://cdn.discordapp.com/attachments/1207384388602560562/1344881154528116777/onionoff.png");
public static bool EnableEfDebugLogging => config.GetValue(nameof(EnableEfDebugLogging), false);
internal static class AllowedMentions
{
internal static readonly IMention[] UsersOnly = [UserMention.All];
@@ -276,7 +277,7 @@ internal static class Config
};
watchdogTarget.Parameters.AddRange([new MethodCallParameter("${level}"), new("${message}")]);
#if DEBUG
loggingConfig.AddRule(LogLevel.Error, LogLevel.Fatal, consoleTarget);
loggingConfig.AddRule(LogLevel.Debug, LogLevel.Fatal, consoleTarget);
loggingConfig.AddRule(LogLevel.Trace, LogLevel.Fatal, consoleTarget, "default"); // echo all messages from default logger to the console
#else
loggingConfig.AddRule(LogLevel.Info, LogLevel.Fatal, consoleTarget, "default");

View File

@@ -23,9 +23,8 @@ internal class BotDb: DbContext
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var dbPath = DbImporter.GetDbPath("bot.db", Environment.SpecialFolder.ApplicationData);
#if DEBUG
optionsBuilder.UseLoggerFactory(Config.LoggerFactory);
#endif
if (Config.EnableEfDebugLogging)
optionsBuilder.UseLoggerFactory(Config.LoggerFactory);
optionsBuilder.UseSqlite($""" Data Source="{dbPath}" """);
}

View File

@@ -11,9 +11,8 @@ internal class HardwareDb : DbContext
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var dbPath = DbImporter.GetDbPath("hw.db", Environment.SpecialFolder.LocalApplicationData);
#if DEBUG
optionsBuilder.UseLoggerFactory(Config.LoggerFactory);
#endif
if (Config.EnableEfDebugLogging)
optionsBuilder.UseLoggerFactory(Config.LoggerFactory);
optionsBuilder.UseSqlite($""" Data Source="{dbPath}" """);
}

View File

@@ -18,9 +18,8 @@ internal class ThumbnailDb : DbContext
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var dbPath = DbImporter.GetDbPath("thumbs.db", Environment.SpecialFolder.LocalApplicationData);
#if DEBUG
optionsBuilder.UseLoggerFactory(Config.LoggerFactory);
#endif
if (Config.EnableEfDebugLogging)
optionsBuilder.UseLoggerFactory(Config.LoggerFactory);
optionsBuilder.UseSqlite($""" Data Source="{dbPath}" """);
}