public void Log(IWork work, logType type, string message) { lock (_logList) { if (_lastLog.Type != type || _lastLog.Message != message) _logList.Add(_lastLog = new logLine(type, message)); if (!String.IsNullOrEmpty(_fileName) && (type == logType.error || type == logType.success)) using (StreamWriter sw = new StreamWriter(File.OpenWrite(_fileName))) foreach (var line in _logList) sw.WriteLine(String.Format("[{0}] {1} - {2}", line.Time, line.Type.ToString(), line.Message)); } }
public void Log(IWork work, logType type, string message) { lock (_logList) { if (_lastLog.Type != type || _lastLog.Message != message) { _logList.Add(_lastLog = new logLine(type, message)); } if (!String.IsNullOrEmpty(_fileName) && (type == logType.error || type == logType.success)) { using (StreamWriter sw = new StreamWriter(File.OpenWrite(_fileName))) foreach (var line in _logList) { sw.WriteLine(String.Format("[{0}] {1} - {2}", line.Time, line.Type.ToString(), line.Message)); } } } }