Ejemplo n.º 1
0
        public static void Write(Exception ex)
        {
            Initialize();

            ExceptionLoggerEntry entry = new ExceptionLoggerEntry(ex);

            lock (_lock)
            {
                foreach (ILogger logger in _loggers)
                {
                    logger.Write(entry);
                }
            }
        }
Ejemplo n.º 2
0
        public override void Write(ILoggerEntry entry)
        {
            try
            {
                if (base._enabled)
                {
                    ConsoleColor foregroundColor = ConsoleColor.Gray;

                    if (entry is ConsoleLoggerEntry)
                    {
                        ConsoleLoggerEntry consoleEntry = (ConsoleLoggerEntry)entry;
                        foregroundColor = consoleEntry.Color;
                    }
                    else
                    if (entry is ConsoleExceptionLoggerEntry)
                    {
                        ConsoleExceptionLoggerEntry consoleEntry = (ConsoleExceptionLoggerEntry)entry;
                        foregroundColor = consoleEntry.Color;
                    }
                    else
                    if (entry is ExceptionLoggerEntry)
                    {
                        ExceptionLoggerEntry consoleEntry = (ExceptionLoggerEntry)entry;
                        foregroundColor = ConsoleColor.Red;
                    }
                    else
                    if (entry is LoggerEntry)
                    {
                        LoggerEntry consoleEntry = (LoggerEntry)entry;
                        foregroundColor = ConsoleColor.Gray;
                    }

                    Console.ForegroundColor = foregroundColor;
                    Console.WriteLine(entry.ToString());
                }
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Unable to write entry!", ex);
            }
        }