예제 #1
0
 public static void Log(LogTitle logTitle, string content, LogLevel logLevel, Exception exception = null)
 {
     //如果这条记录5秒之内插入过,就不再插入
     if (contentList.Exists(t => DateTime.Now.Subtract(t.x).TotalSeconds < 9 && t.y == content))
     {
         return;
     }
     if (contentList.Count > 50)
     {
         contentList.RemoveAt(0);
     }
     contentList.Add(new Generics <DateTime, string>(DateTime.Now, content));
     LogWrite?.Invoke(null, LogEventArgs.GetLogEventArgs(logTitle, content, logLevel, exception));
 }
예제 #2
0
 /// <summary>
 /// Write to the log
 /// </summary>
 /// <param name="level">Log level</param>
 /// <param name="text">Text with format</param>
 /// <param name="args">Format args</param>
 public static void Write(LogLevel level, string text, params object[] args)
 {
     try
     {
         if (args != null && args.Length != 0)
         {
             text = string.Format(text, args);
         }
         logger?.Log(GetNLogLevel(level), text);
         LogWrite?.Invoke(new LoggerEvent()
         {
             level = level, text = text, args = args
         });
     }
     catch
     {
         // oh well...
     }
 }
예제 #3
0
 public static void Log(LogTitle logTitle, string content, LogLevel logLevel, Exception exception = null)
 {
     LogWrite?.Invoke(null, LogEventArgs.GetLogEventArgs(logTitle, content, logLevel, exception));
 }
예제 #4
0
 public static void Write(string msg)
 {
     LogWrite?.Invoke(msg);
 }