protected internal override void DoLog(LogCatagory catagory, string message) { if (Environment.UserInteractive) { lock (_consoleLock) { ConsoleColor defaultColour = Console.ForegroundColor; switch (catagory) { case LogCatagory.Debug: Console.ForegroundColor = ConsoleColor.Gray; break; case LogCatagory.Warn: Console.ForegroundColor = ConsoleColor.Yellow; break; case LogCatagory.Error: Console.ForegroundColor = ConsoleColor.Red; break; } Console.WriteLine(message); Console.ForegroundColor = defaultColour; } } if (_logger != null) { _logger.DoLog(catagory, message); } }
protected internal override void DoLog(LogCatagory catagory, string message) { if (catagory != LogCatagory.Debug) // TODO: Take this from configuration, rather than hard code. { _fileWriter.Write(_filePath, message); } if (_logger != null) { _logger.DoLog(catagory, message); } }
protected internal override void DoLog(LogCatagory catagory, string message) { if (Environment.UserInteractive) { _consoleLogger.DoLog(catagory, message); } if (catagory == LogCatagory.Debug) { return; // TODO: Take this from configuration, rather than hard code. } _fileLogger.DoLog(catagory, message); }
private static EventLogEntryType GetLogType(LogCatagory category) { switch (category) { case LogCatagory.Unknown: return(EventLogEntryType.Error); case LogCatagory.Debug: return(EventLogEntryType.Information); case LogCatagory.Info: return(EventLogEntryType.Information); case LogCatagory.Warn: return(EventLogEntryType.Warning); case LogCatagory.Error: return(EventLogEntryType.Error); default: return(EventLogEntryType.Error); } }
protected internal override void DoLog(LogCatagory catagory, string message) { _eventLog.WriteEntry(message, GetLogType(catagory)); _fileWriter.Write(_logFilePath, message); }
protected internal abstract void DoLog(LogCatagory catagory, string message);
protected virtual string CreateLog(LogCatagory catagory, string message, params object[] args) { return(String.Format("{0} {1}: {2} - {3}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), Caller, catagory, args.Any() ? String.Format(message, args) : message)); }
public virtual void Log(LogCatagory catagory, Exception e, string message, params object[] args) { DoLog(catagory, CreateErrorLog(CreateLog(catagory, message, args), e)); }
public virtual void Log(LogCatagory catagory, Exception e, string message) { Log(catagory, e, message, new object[0]); }
public virtual void Log(LogCatagory catagory, string message, params object[] args) { DoLog(catagory, CreateLog(catagory, message, args)); }