private static LogConfig ReadLogConfig() { var logConfig = new LogConfig(); if (!File.Exists(LogConfigPath)) { return(logConfig); } using (var sr = new StreamReader(LogConfigPath)) { LogConfigItem current = null; string line; while (!sr.EndOfStream && (line = sr.ReadLine()) != null) { var match = 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, LogLevelRegex, ref current.LogLevel)) { continue; } if (TryParseLine(line, FilePrintingRegex, ref current.FilePrinting)) { continue; } if (TryParseLine(line, ConsolePrintingRegex, ref current.ConsolePrinting)) { continue; } if (TryParseLine(line, ScreenPrintingRegex, ref current.ScreenPrinting)) { continue; } var verbose = false; if (TryParseLine(line, VerboseRegex, ref verbose)) { current.Verbose = verbose; } } } return(logConfig); }
private static LogConfig ReadLogConfig() { var logConfig = new LogConfig(); if(!File.Exists(LogConfigPath)) return logConfig; using(var sr = new StreamReader(LogConfigPath)) { LogConfigItem current = null; string line; while(!sr.EndOfStream && (line = sr.ReadLine()) != null) { var match = 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, LogLevelRegex, ref current.LogLevel)) continue; if(TryParseLine(line, FilePrintingRegex, ref current.FilePrinting)) continue; if(TryParseLine(line, ConsolePrintingRegex, ref current.ConsolePrinting)) continue; if(TryParseLine(line, ScreenPrintingRegex, ref current.ScreenPrinting)) continue; var verbose = false; if(TryParseLine(line, VerboseRegex, ref verbose)) current.Verbose = verbose; } } return logConfig; }
public void Add(LogConfigItem configItem) { Log.Info($"Adding {configItem.Name}"); Items.Add(configItem); Updated = true; }