Пример #1
0
        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);
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
            }
        }
Пример #5
0
 protected internal override void DoLog(LogCatagory catagory, string message)
 {
     _eventLog.WriteEntry(message, GetLogType(catagory));
     _fileWriter.Write(_logFilePath, message);
 }
Пример #6
0
 protected internal abstract void DoLog(LogCatagory catagory, string message);
Пример #7
0
 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));
 }
Пример #8
0
 public virtual void Log(LogCatagory catagory, Exception e, string message, params object[] args)
 {
     DoLog(catagory, CreateErrorLog(CreateLog(catagory, message, args), e));
 }
Пример #9
0
 public virtual void Log(LogCatagory catagory, Exception e, string message)
 {
     Log(catagory, e, message, new object[0]);
 }
Пример #10
0
 public virtual void Log(LogCatagory catagory, string message, params object[] args)
 {
     DoLog(catagory, CreateLog(catagory, message, args));
 }