Пример #1
0
 public LogMessage(DateTime timestamp, int threadId, CoreLogLevel level, string message, Exception exception)
 {
     Timestamp = timestamp;
     ThreadId  = threadId;
     Level     = level;
     Message   = message;
     Exception = exception;
 }
Пример #2
0
        public static void Log(CoreLogLevel level, string message)
        {
            var tw = TextWriter;

            if (tw != null && (LogLevel >= level || level == CoreLogLevel.Initialisation))
            {
                tw.WriteLine(level == CoreLogLevel.Initialisation ? message : $"[SampSharp:{GetLevelName(level)}] {message}");
            }
        }
Пример #3
0
 public static void Log(CoreLogLevel level, string message)
 {
     if (Stream != null && (LogLevel >= level || level == CoreLogLevel.Initialisation))
     {
         using (var sw = new StreamWriter(Stream, Encoding.ASCII, 1024, true))
         {
             sw.WriteLine(level == CoreLogLevel.Initialisation ? message : $"[SampSharp:{GetLevelName(level)}] {message}");
         }
     }
 }
Пример #4
0
        public void Log(CoreLogLevel loglevel, string message, Exception exception)
        {
            var hasGlobalListeners = GlobalLogger.HasListeners;

            var newlog = new LogMessage(DateTime.UtcNow, Environment.CurrentManagedThreadId, loglevel, message, exception);

            if (hasGlobalListeners)
            {
                GlobalLogger.Publish(newlog);
            }
        }
Пример #5
0
 public static bool DoesLog(CoreLogLevel level)
 {
     return(LogLevel >= level || level == CoreLogLevel.Initialisation);
 }
Пример #6
0
 private static string GetLevelName(CoreLogLevel level)
 {
     return(level.ToString().ToUpper());
 }
Пример #7
0
 /// <summary>
 ///     Uses the specified log level as the maximum level which is written to the log by SampSharp.
 /// </summary>
 /// <param name="logLevel">The log level.</param>
 /// <returns>The updated game mode configuration builder.</returns>
 public GameModeBuilder UseLogLevel(CoreLogLevel logLevel)
 {
     CoreLog.LogLevel = logLevel;
     return(this);
 }