public Initializer(string settingsProfileName) { new FileChecker(); var di = DiContainer.Container; _logger = di.Locate <MainLogger>(); Settings = di.Locate <Settings>(); if (!string.IsNullOrEmpty(settingsProfileName)) { Settings.ConfigFileName = Settings.ConfigFileName.Replace(".ini", $".{settingsProfileName}.ini"); } Settings.Load(); var saver = di.Locate <MainSaver>(); if (Settings.Get <bool>(_names.Console)) { _logger.AddLogger(new ConsoleLogger(Settings)); } else { _logger.AddLogger(new EmptyLogger()); } _logger.AddLogger(new FileLogger(saver, Settings)); #if !DEBUG _logger.AddLogger(new SentryLogger()); #endif _logger.Log("Created DI container", LogLevel.Basic); }
public Initializer() { new FileChecker(); var di = DiContainer.Container; _logger = di.Locate <MainLogger>(); var saver = di.Locate <MainSaver>(); Settings = di.Locate <Settings>(); Settings.Load(); if (Settings.Get <bool>(_names.Console)) { _logger.AddLogger(new ConsoleLogger(Settings)); } else { _logger.AddLogger(new EmptyLogger()); } _logger.AddLogger(new FileLogger(saver, Settings)); #if !DEBUG _logger.AddLogger(new SentryLogger()); #endif _logger.Log("Created DI container", LogLevel.Basic); }
public Initializer() { new FileChecker(); _saver = new MainSaver(_logger); this.Settings = new Settings(_logger); Settings.SetSavePath(ConfigSaveLocation); Settings.Load(); if (Settings.Get <bool>(_names.Console)) { _logger.ChangeLogger(new ConsoleLogger(Settings)); } else { _logger.ChangeLogger(new EmptyLogger()); } _logger.AddLogger(new FileLogger(_saver, Settings)); #if !DEBUG _logger.AddLogger(new SentryLogger()); #endif _logger.Log("booting up...", LogLevel.Basic); }
private void SettingUpdated(object sender, SettingUpdated e) { if (e.Name == _names.Console.Name) { if (settings.Get <bool>(_names.Console)) { mainLogger.AddLogger(new ConsoleLogger(settings)); } else { var logger = mainLogger.Loggers.FirstOrDefault(x => x is ConsoleLogger); if (logger != null) { mainLogger.RemoveLogger(logger); } } } }