Logger Class

Project : Core



 
public delegate void STDOUT(String text);
 
    class Logger 
    {
        public const String MODE_DEBUG = "DEBUG";
        public const String MODE_ERROR = "ERROR";
        public const String MODE_SCIENCE = "OFF";
 
        public static String mode = Logger.MODE_DEBUG;
 
        public static STDOUT stdout;
 
        public static void setOutPut(STDOUT method) {
            stdout = method;
        }
 
        public static void Key()
        {
            if(mode==MODE_DEBUG)
                Console.ReadKey();
        }
 
        public static void Pause()
        {
                Console.ReadKey();
        }
 
        public static void Log(String txt)
        {
            if (mode == MODE_DEBUG || (mode == MODE_ERROR) )
                StdOut("LOG:" + txt);
        }
 
        public static void Debug(String txt)
        {
            if (mode == MODE_DEBUG)
                StdOut("DEBUG:" + txt);
        }
 
        public static void Print(String txt)
        {
                StdOut(" " + txt);
        }
 
        public static void Error(String txt)
        {
                StdOut("ERROR:" + txt);
        }
 
        public static void Error(Exception e)
        {
            StdOut("ERROR:" + e.Message);
        }
 
        static void StdOut(String txt)
        {
            if (stdout == null) 
                Console.WriteLine(txt);
            else 
                stdout(txt);    
        }
    }
 

by TALF Colombia.(R) 2018