internal static bool LoadConfig() { // Validate current config path exists, otherwise set the default if (string.IsNullOrWhiteSpace(Program.Config.ConfigFilePath)) { Program.Config.ConfigFilePath = $@"{Program.Config.DirConfig}\config.json"; } if (!WTFile.DirectoryExists(Program.Config.DirConfig)) { Events.Log("Creating non-existant config directory"); Directory.CreateDirectory(Program.Config.DirConfig); } if (!WTFile.FileExists(Program.Config.ConfigFilePath)) { return(false); } // Import config if config file exists try { var configLoaded = File.ReadAllText(Program.Config.ConfigFilePath); Program.Config = JsonConvert.DeserializeObject <Config>(configLoaded); } catch (Exception ex) { Events.Log(ex.Message, Discord.LogSeverity.Critical); } return(true); }
public static void InitializeLogger() { Logger = new LoggerConfiguration() .WriteTo.File($"{WTFile.GetLoggingPath()}\\MangoTime.log", rollingInterval: RollingInterval.Day) .MinimumLevel.ControlledBy(LevelSwitch) .CreateLogger(); #if DEBUG LevelSwitch.MinimumLevel = LogEventLevel.Debug; #else LevelSwitch.MinimumLevel = LogEventLevel.Information; #endif Logger.Information("Logger started"); }