/// <summary> Initializes NLog-based loggers. Repeated initialization is being skipped. </summary> public static void InitializeLoggers() { if (_loggersInitialized) { return; } var fileLogger = new ConfiguredNLogger(ELoggerName.FileLogger, new ExceptionFormatter(), ESubdirectory.Logs, true); var wpfLogger = new ConfiguredNLogger(ELoggerName.WpfLogger, new ExceptionFormatter()); wpfLogger.LogInstantiation(fileLogger); Loggers = new IConfiguredLogger[] { fileLogger, wpfLogger, }; Log = CreateActiveLogger(EWpfClientLogCategory.ApplicationHelpers); Log.Debug(ECoreLogMessage.InstanceInitialised.FormatFluently(EWord.Loggers)); _loggersInitialized = true; }
/// <summary> The entry point. </summary> static void Main() { System.Console.Title = EClientApplicationName.WarThunderPresetRandomizer; var defaultColor = ConsoleColor.Gray; var requiredSettings = new List <string> { nameof(Settings.WarThunderLocation), nameof(Settings.KlensysWarThunderToolsLocation), }; try { var loggers = new IConfiguredLogger[] { new ConfiguredNLogger(ELoggerName.FileLogger, new ExceptionFormatter(), ESubdirectory.Logs), new ConfiguredNLogger(ELoggerName.ConsoleLogger, new ExceptionFormatter()), }; var fileManager = new WarThunderFileManager(loggers); var fileReader = new WarThunderFileReader(loggers); var settingsManager = new WarThunderSettingsManager(fileManager, EConsoleClientFile.Settings, requiredSettings, loggers); var parser = new Parser(loggers); var unpacker = new Unpacker(fileManager, loggers); var dataRepositoryFactory = new DataRepositoryFactoryWarThunder(loggers); var converter = new Converter(loggers); var jsonHelper = new WarThunderJsonHelper(loggers); var csvDeserializer = new CsvDeserializer(loggers); var randomiser = new CustomRandomiser(loggers); var vehicleSelector = new VehicleSelector(randomiser, loggers); var presetGenerator = new PresetGenerator(randomiser, vehicleSelector, loggers); var thunderSkillParser = new ThunderSkillParser(loggers); using (var manager = new Manager(fileManager, fileReader, settingsManager, parser, unpacker, converter, jsonHelper, csvDeserializer, dataRepositoryFactory, randomiser, vehicleSelector, presetGenerator, thunderSkillParser, true, false, false, loggers)) { manager.RemoveOldLogFiles(); manager.InitialiseGameClientVersion(); while (!settingsManager.WarThunderLocationIsValid()) { System.Console.Write(EConsoleUiLogMessage.SelectValidLocation.Format(EApplicationName.WarThunder)); settingsManager.Save(nameof(Settings.WarThunderLocation), System.Console.ReadLine()); } while (!settingsManager.KlensysWarThunderToolLocationIsValid()) { System.Console.Write(EConsoleUiLogMessage.SelectValidLocation.Format(EApplicationName.KlensysWarThunderTools)); settingsManager.Save(nameof(Settings.KlensysWarThunderToolsLocation), System.Console.ReadLine()); } System.Console.WriteLine(); manager.CacheData(); while (true) { var specification = ParseSpecification ( TakeSpecificationInput(), manager .ResearchTrees .SelectMany(nationResearchTreeKeyValuePair => nationResearchTreeKeyValuePair.Value) .SelectMany(branchKeyValuePair => branchKeyValuePair.Value) .SelectMany(rankKeyValuePair => rankKeyValuePair.Value) .Select(rankVehicleKeyValuePair => rankVehicleKeyValuePair.Value.GaijinId) ); foreach (var vehicle in manager.GeneratePrimaryAndFallbackPresets(specification)[EPreset.Primary]) { System.Console.ForegroundColor = !vehicle.IsResearchable ? ConsoleColor.Yellow : ConsoleColor.White; System.Console.WriteLine($"\t {vehicle.BattleRatingFormatted[specification.GameMode]} {vehicle.GaijinId}"); } System.Console.ForegroundColor = defaultColor; } } } catch { System.Console.Write($"\n{ECoreLogMessage.AnErrorHasOccurred} {EConsoleUiLogMessage.PressAnyKeyToExit} "); System.Console.ReadKey(true); Environment.Exit(0); } }
/// <summary> Logs intantiation of this logger. It is done here so that the event of intantiation could be logged by any logger. </summary> /// <param name="logger"> The logger to log with. </param> public void LogInstantiation(IConfiguredLogger logger) => logger.LogDebug(ECoreLogCategory.Logger, ECoreLogMessage.Created.Format(_logger.Name));