Пример #1
0
        internal void LogHandler(object sender, DebugLogMessageEventArgs e)
        {
#if !NETSTANDARD1_1
            switch (e.Level)
            {
            case LogLevel.Debug:
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                break;

            case LogLevel.Info:
                Console.ForegroundColor = ConsoleColor.White;
                break;

            case LogLevel.Warning:
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                break;

            case LogLevel.Error:
                Console.ForegroundColor = ConsoleColor.DarkRed;
                break;

            case LogLevel.Critical:
                Console.BackgroundColor = ConsoleColor.DarkRed;
                Console.ForegroundColor = ConsoleColor.Black;
                break;
            }

            Console.Write($"[{e.Timestamp.ToString(this.DateTimeFormat)}] [{e.Application}] [{e.Level}]");
            Console.ResetColor();
            Console.WriteLine($" {e.Message}{(e.Exception != null ? $"\n{e.Exception}" : "")}");
#endif
        }
Пример #2
0
        internal void LogHandler(object sender, DebugLogMessageEventArgs e)
        {
            switch (e.Level)
            {
            case LogLevel.Unnecessary:
            {
                Console.ForegroundColor = ConsoleColor.DarkGray;
                break;
            }

            case LogLevel.Debug:
            {
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                break;
            }

            case LogLevel.Info:
            {
                Console.ForegroundColor = ConsoleColor.White;
                break;
            }

            case LogLevel.Warning:
            {
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                break;
            }

            case LogLevel.Error:
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                break;
            }

            case LogLevel.Critical:
            {
                Console.BackgroundColor = ConsoleColor.DarkRed;
                Console.ForegroundColor = ConsoleColor.Black;
                break;
            }
            }

            Console.Write($"[{e.Application.ToUpper()}] {e.TimeStamp} | {e.Level.ToString().ToUpper()}:");
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine($" {e.Message}");
        }
Пример #3
0
 private void DebugLogger_LogMessageReceived(object sender, DebugLogMessageEventArgs e)
 => this.DebugLogger.LogMessage(e.Level, e.Application, e.Message, e.Timestamp);