Пример #1
0
        public static void ShowWarning(string ex, LoggerOld log)
        {
            if (!defaultLoggerOld.LogLevel.Test(LogContent.Warning))
            {
                return;
            }

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write("[Warning]");
            Console.ResetColor();
            Console.WriteLine(ex);
            log?.WriteLog("Warning:" + ex);
        }
Пример #2
0
        public static void ShowInfo(string ex, LoggerOld log)
        {
            if (!defaultLoggerOld.LogLevel.Test(LogContent.Info))
            {
                return;
            }

            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write("[Info]");
            Console.ResetColor();
            Console.WriteLine(ex);
            log?.WriteLog(ex);
        }
Пример #3
0
        public static void ShowWarning(Exception ex, LoggerOld log)
        {
            if (!defaultLoggerOld.LogLevel.Test(LogContent.Warning))
            {
                return;
            }

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write("[Warning]");
            Console.ResetColor();
            Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
            log?.WriteLog("Warning:" + ex.ToString());
        }
Пример #4
0
        public static void ShowSQL(String ex, LoggerOld log)
        {
            if (!defaultLoggerOld.LogLevel.Test(LogContent.SQL))
            {
                return;
            }

            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.Write("[SQL]");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(ex);
            Console.ResetColor();
            log?.WriteLog("[SQL]" + ex);
        }
Пример #5
0
        public static void ShowSQL(Exception ex, LoggerOld log)
        {
            if (!defaultLoggerOld.LogLevel.Test(LogContent.SQL))
            {
                return;
            }

            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.Write("[SQL]");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(ex.Message + "\r\n" + FilterSQL(ex.StackTrace));
            Console.ResetColor();
            log?.WriteLog("[SQL]" + ex.Message + "\r\n" + FilterSQL(ex.StackTrace));
        }
Пример #6
0
        public static void ShowDebug(Exception ex, LoggerOld log)
        {
            if (!defaultLoggerOld.LogLevel.Test(LogContent.Warning))
            {
                return;
            }

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Write("[Debug]");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
            Console.ResetColor();
            log?.WriteLog("[Debug]" + ex.Message + "\r\n" + ex.StackTrace);
        }
Пример #7
0
        public static void ShowDebug(string ex, LoggerOld log)
        {
            if (!defaultLoggerOld.LogLevel.Test(LogContent.Debug))
            {
                return;
            }

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Write("[Debug]");
            Console.ForegroundColor = ConsoleColor.White;
            StackTrace Stacktrace = new StackTrace(1, true);
            string     txt        = ex;

            foreach (StackFrame i in Stacktrace.GetFrames())
            {
                txt = txt + "\r\n      at " + i.GetMethod().ReflectedType.FullName + "." + i.GetMethod().Name + " " + i.GetFileName() + ":" + i.GetFileLineNumber();
            }
            txt = FilterSQL(txt);
            Console.WriteLine(txt);
            Console.ResetColor();
            log?.WriteLog("[Debug]" + txt);
        }
Пример #8
0
        public static void ShowError(string ex, LoggerOld log)
        {
            try
            {
                if (!defaultLoggerOld.LogLevel.Test(LogContent.Error))
                {
                    return;
                }

                if (log == null)
                {
                    log = defaultLoggerOld;
                }

                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("[Error]");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine(ex);
                Console.ResetColor();
                log.WriteLog("[Error]" + ex);
            }
            catch { }
        }
Пример #9
0
 public static void ShowInfo(Exception ex, LoggerOld log)
 {
     ShowInfo(ex.Message + "\r\n" + ex.StackTrace, log);
 }