Пример #1
0
 public LogEntry(object message, object args, SendingLogger logger = SendingLogger.CONSOLE, ConsoleColor?color = null)
 {
     this.target  = null;
     this.thread  = Thread.CurrentThread;
     this.time    = DateTime.Now;
     this.message = message;
     this.args    = args;
     this.channel = null;
     this.logger  = logger;
     this.color   = color;
 }
Пример #2
0
 static void Send(LogTarget target, OutputEntry output)
 {
     if (target == null)
     {
         lock (logTargets)
             foreach (var tar in logTargets)
             {
                 tar.Send(output);
             }
     }
     else
     {
         target.Send(output);
     }
 }
Пример #3
0
        public static void OpenLogFile(string path)
        {
            var newpath = path;

            if (LogRotation)
            {
                var absolute = Path.GetFullPath(path);
                var dir      = Path.GetDirectoryName(absolute);
                var name     = Path.GetFileNameWithoutExtension(path);
                var ext      = Path.GetExtension(path);
                newpath = Path.Combine(dir, String.Format("{0}_{1:yyyyMMdd_HHmm}{2}", name, DateTime.Now, ext));
            }

            logFile = new FileOutputTarget(newpath);

            lock (logTargets)
                logTargets.Add(logFile);

            Log("Logging started to file \"{0}\".", newpath);
        }
Пример #4
0
 public static void AddTarget(LogTarget target)
 {
     lock (logTargets) logTargets.Add(target);
 }
Пример #5
0
 public static void RemoveTarget(LogTarget target)
 {
     lock (logTargets) logTargets.Remove(target);
 }