Ejemplo n.º 1
0
 public LogMessage(DateTime timestamp, int threadId, CoreLogLevel level, string message, Exception exception)
 {
     Timestamp = timestamp;
     ThreadId  = threadId;
     Level     = level;
     Message   = message;
     Exception = exception;
 }
Ejemplo n.º 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}");
            }
        }
Ejemplo n.º 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}");
         }
     }
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 5
0
 public static bool DoesLog(CoreLogLevel level)
 {
     return(LogLevel >= level || level == CoreLogLevel.Initialisation);
 }
Ejemplo n.º 6
0
 private static string GetLevelName(CoreLogLevel level)
 {
     return(level.ToString().ToUpper());
 }
Ejemplo n.º 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);
 }