Beispiel #1
0
 public void Log(TaskInfo info)
 {
     if (writer == null) return;
     if (onlyErrors && !(info is TaskError)) return;
     writer.WriteLine("[{0}] {1}: ({2}) {3}",
         info.Timestamp.ToString("yyyy-MM-dd HH-mm-ss"),
         info is TaskError ? "ERROR" : "INFO",
         info.AppId ?? "global",
         info.Message);
     if (info.DetailedMessage != null)
     {
         writer.WriteLine("[{0}] DETAIL:",
             info.Timestamp.ToString("yyyy-MM-dd HH-mm-ss"));
         writer.WriteLine(info.DetailedMessage);
     }
     var err = info as TaskError;
     if (err != null)
     {
         if (err.Exception != null)
         {
             writer.Write("[{0}] EXCEPTION: ",
                 info.Timestamp.ToString("yyyy-MM-dd HH-mm-ss"));
             writer.WriteLine(err.Exception.ToString());
         }
     }
     writer.Flush();
 }
        private void NotificationHandler(TaskInfo info)
        {
            var err = info as TaskError;

            if (!Verbose && err == null) return;

            lock (consoleSyncHandle)
            {
                if (err != null) Console.ForegroundColor = ConsoleColor.Red;

                Console.WriteLine(
                    "[{0}] ({1}) {2}",
                    info is TaskError ? "ERROR" : "INFO",
                    info.AppId ?? "global",
                    info.Message);

                if (info.DetailedMessage != null)
                {
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Console.WriteLine(info.DetailedMessage);
                }
                if (err != null && err.Exception != null)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine(err.Exception.ToString());
                }
                Console.ResetColor();
            }
        }