private static LogConfig ReadLogConfig() { var logConfig = new LogConfig(); if (!File.Exists(LogConfigConstants.LogConfigPath)) { return(logConfig); } using (var sr = new StreamReader(LogConfigConstants.LogConfigPath)) { LogConfigItem current = null; string line; while (!sr.EndOfStream && (line = sr.ReadLine()) != null) { var match = LogConfigConstants.NameRegex.Match(line); if (match.Success) { current = new LogConfigItem(match.Groups["value"].Value); logConfig.Items.Add(current); continue; } if (current == null) { continue; } if (TryParseLine(line, LogConfigConstants.LogLevelRegex, ref current.LogLevel)) { continue; } if (TryParseLine(line, LogConfigConstants.FilePrintingRegex, ref current.FilePrinting)) { continue; } if (TryParseLine(line, LogConfigConstants.ConsolePrintingRegex, ref current.ConsolePrinting)) { continue; } if (TryParseLine(line, LogConfigConstants.ScreenPrintingRegex, ref current.ScreenPrinting)) { continue; } var verbose = false; if (TryParseLine(line, LogConfigConstants.VerboseRegex, ref verbose)) { current.Verbose = verbose; } } } return(logConfig); }
public void Add(LogConfigItem configItem) { Log.Info($"Adding {configItem.Name}"); Items.Add(configItem); Updated = true; }