Пример #1
0
        private void WriteBulk(string bulk, LogMessageClass c)
        {
            using (new ConsoleColorScope(GetForeground(c), GetBackground(c)).Enter())
            {
                var outputStream = c == LogMessageClass.Error
                                        ? Console.Error
                                        : Console.Out;

                outputStream.Write(bulk);
            }
        }
Пример #2
0
        protected virtual ConsoleColor?GetForeground(LogMessageClass messageClass)
        {
            switch (messageClass)
            {
            case LogMessageClass.Debug:
                return(ConsoleColor.DarkGray);

            case LogMessageClass.Warning:
                return(ConsoleColor.Yellow);

            case LogMessageClass.Error:
                return(ConsoleColor.Red);
            }

            return(null);
        }
Пример #3
0
        private static string ClassToString(LogMessageClass @class)
        {
            switch (@class)
            {
            case LogMessageClass.Debug:
                return("DEBUG");

            case LogMessageClass.Verbose:
                return("VERBOSE");

            case LogMessageClass.Information:
                return("NOTICE");

            case LogMessageClass.Warning:
                return("WARNING");

            case LogMessageClass.Error:
                return("ERROR");
            }

            return(null);
        }
Пример #4
0
 public void Write(string message, LogMessageClass messageClass = LogMessageClass.Information)
 {
     Dispatch(new LogMessage {
         Text = message, Class = messageClass, Scope = MessageScope.State, Timestamp = DateTime.Now
     });
 }
Пример #5
0
    static void Main(string[] args)
    {
        CustomTimerClass ctc = new CustomTimerClass();

        DisplayMessageClass dmc = new DisplayMessageClass (ctc);
        LogMessageClass lmc = new LogMessageClass (ctc);

        // Run the CustomTimerClass.
        ctc.Run();

        Console.Write ("\nPress <ENTER> to end: ");
        Console.Read();
    }
Пример #6
0
 protected virtual ConsoleColor?GetBackground(LogMessageClass messageClass) => null;