Ejemplo n.º 1
0
        public void LogFormat(LoggingLevel level, string format, params object[] args)
        {
            if (_level < level)
                return;

            LogInternal(level, string.Format(format, args), null);
        }
Ejemplo n.º 2
0
        public void Log(LoggingLevel level, object obj)
        {
            // Map topshelf loglevel to liblog loglevel
            var logLevel = MapLogLevel(level);

            // Don't log anything if loglevel is not specified
            if (logLevel == null) return;

            _logger.Log(logLevel.Value, () => FormatObject(obj));
        }
Ejemplo n.º 3
0
 public void Log(LoggingLevel level, LogWriterOutputProvider messageProvider)
 {
     if (level == LoggingLevel.Fatal)
         Fatal(messageProvider);
     else if (level == LoggingLevel.Error)
         Error(messageProvider);
     else if (level == LoggingLevel.Warn)
         Warn(messageProvider);
     else if (level == LoggingLevel.Info)
         Info(messageProvider);
     else if (level >= LoggingLevel.Debug)
         Debug(messageProvider);
 }
Ejemplo n.º 4
0
 public void Log(LoggingLevel level, object obj, Exception exception)
 {
     if (level == LoggingLevel.Fatal)
         Fatal(obj, exception);
     else if (level == LoggingLevel.Error)
         Error(obj, exception);
     else if (level == LoggingLevel.Warn)
         Warn(obj, exception);
     else if (level == LoggingLevel.Info)
         Info(obj, exception);
     else if (level >= LoggingLevel.Debug)
         Debug(obj, exception);
 }
Ejemplo n.º 5
0
 static LogEventLevel TopshelfToSerilogLevel(LoggingLevel level)
 {
     if (level == LoggingLevel.All)
         return LogEventLevel.Verbose;
     if (level == LoggingLevel.Debug)
         return LogEventLevel.Debug;
     if (level == LoggingLevel.Info)
         return LogEventLevel.Information;
     if (level == LoggingLevel.Warn)
         return LogEventLevel.Warning;
     if (level == LoggingLevel.Error)
         return LogEventLevel.Error;
     return LogEventLevel.Fatal;
 }
Ejemplo n.º 6
0
        public void Log(LoggingLevel level, object obj, Exception exception)
        {
            // If exception is null, use log method without exception
            if (exception == null)
            {
                Log(level, obj);
                return;
            }

            // Map topshelf loglevel to liblog loglevel
            var logLevel = MapLogLevel(level);

            // Don't log anything if loglevel is not specified
            if (logLevel == null) return;

            _logger.Log(logLevel.Value, () => FormatObject(obj), exception);
        }
Ejemplo n.º 7
0
 public void LogFormat(LoggingLevel level, string format, params object[] args)
 {
     if (level == LoggingLevel.Fatal)
     {
         FatalFormat(CultureInfo.InvariantCulture, format, args);
     }
     else if (level == LoggingLevel.Error)
     {
         ErrorFormat(CultureInfo.InvariantCulture, format, args);
     }
     else if (level == LoggingLevel.Warn)
     {
         WarnFormat(CultureInfo.InvariantCulture, format, args);
     }
     else if (level == LoggingLevel.Info)
     {
         InfoFormat(CultureInfo.InvariantCulture, format, args);
     }
     else if (level >= LoggingLevel.Debug)
     {
         DebugFormat(CultureInfo.InvariantCulture, format, args);
     }
 }
Ejemplo n.º 8
0
 public void Log(LoggingLevel level, object obj, Exception exception)
 {
     if (level == LoggingLevel.Fatal)
     {
         Fatal(obj, exception);
     }
     else if (level == LoggingLevel.Error)
     {
         Error(obj, exception);
     }
     else if (level == LoggingLevel.Warn)
     {
         Warn(obj, exception);
     }
     else if (level == LoggingLevel.Info)
     {
         Info(obj, exception);
     }
     else if (level >= LoggingLevel.Debug)
     {
         Debug(obj, exception);
     }
 }
Ejemplo n.º 9
0
 public void LogFormat(LoggingLevel level, IFormatProvider formatProvider, string format, params object[] args)
 {
     if (level == LoggingLevel.Fatal)
     {
         FatalFormat(formatProvider, format, args);
     }
     else if (level == LoggingLevel.Error)
     {
         ErrorFormat(formatProvider, format, args);
     }
     else if (level == LoggingLevel.Warn)
     {
         WarnFormat(formatProvider, format, args);
     }
     else if (level == LoggingLevel.Info)
     {
         InfoFormat(formatProvider, format, args);
     }
     else if (level >= LoggingLevel.Debug)
     {
         DebugFormat(formatProvider, format, args);
     }
 }
Ejemplo n.º 10
0
 public void Log(LoggingLevel level, LogWriterOutputProvider messageProvider)
 {
     if (level == LoggingLevel.Fatal)
     {
         Fatal(messageProvider);
     }
     else if (level == LoggingLevel.Error)
     {
         Error(messageProvider);
     }
     else if (level == LoggingLevel.Warn)
     {
         Warn(messageProvider);
     }
     else if (level == LoggingLevel.Info)
     {
         Info(messageProvider);
     }
     else if (level >= LoggingLevel.Debug)
     {
         Debug(messageProvider);
     }
 }
Ejemplo n.º 11
0
 public TraceLogWriter(TraceSource source)
 {
     _source = source;
     _level = LoggingLevel.FromSourceLevels(source.Switch.Level);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Logs the specified level.
 /// </summary>
 /// <param name="level">The level.</param>
 /// <param name="obj">The object.</param>
 public void Log(LoggingLevel level, object obj) => this.logger.Log(ToLogLevel(level), 0, obj, null, (s, e) => s.ToString());
Ejemplo n.º 13
0
 /// <summary>
 /// Logs the format.
 /// </summary>
 /// <param name="level">The level.</param>
 /// <param name="formatProvider">The format provider.</param>
 /// <param name="format">The format.</param>
 /// <param name="args">The arguments.</param>
 public void LogFormat(LoggingLevel level, IFormatProvider formatProvider, string format, params object[] args) => this.LogFormat(level, format, args);
Ejemplo n.º 14
0
 public void LogFormat(LoggingLevel level, string format, params object[] args)
 {
     _log.Log(GetNLogLevel(level), format, args);
 }
Ejemplo n.º 15
0
 public void Log(LoggingLevel level, object obj, Exception exception)
 {
     if (obj != null)
         _log.Log(GetNLogLevel(level), exception, obj.ToString());
     else
         _log.Log(GetNLogLevel(level), exception);
 }
Ejemplo n.º 16
0
        public void Log(LoggingLevel level, LogWriterOutputProvider messageProvider)
        {
            if (_level < level)
                return;

            object obj = messageProvider();

            LogInternal(level, obj, null);
        }
Ejemplo n.º 17
0
 public void Log(LoggingLevel level, object obj, Exception exception)
 {
     _logger.Write(TopshelfToSerilogLevel(level), exception, ObjectMessageTemplate, obj);
 }
Ejemplo n.º 18
0
 public void LogFormat(LoggingLevel level, string format, params object[] args)
 {
     _log.Log(GetNLogLevel(level), format, args);
 }
Ejemplo n.º 19
0
 public void Log(LoggingLevel level, object obj, Exception exception)
 {
     _log.LogException(GetNLogLevel(level), obj == null
                                                ? ""
                                                : obj.ToString(), exception);
 }
Ejemplo n.º 20
0
 public void Log(LoggingLevel level, object obj, Exception exception)
 {
     _log.LogException(GetNLogLevel(level), obj == null
                                                ? ""
                                                : obj.ToString(), exception);
 }
Ejemplo n.º 21
0
        void LogInternal(LoggingLevel level, object obj, Exception exception)
        {
            string message = obj == null
                                 ? ""
                                 : obj.ToString();

            if (exception == null)
                _source.TraceEvent(level.TraceEventType, 0, message);
            else
                _source.TraceData(level.TraceEventType, 0, (object)message, (object)exception);
        }
Ejemplo n.º 22
0
        public void Log(LoggingLevel level, object obj)
        {
            if (_level < level)
                return;

            LogInternal(level, obj, null);
        }
Ejemplo n.º 23
0
 public void LogFormat(LoggingLevel level, string format, params object[] args)
 {
     _logger.Write(TopshelfToSerilogLevel(level), format, args);
 }
		public void Log(LoggingLevel level, LogWriterOutputProvider messageProvider) {
			throw new NotImplementedException();
		}
Ejemplo n.º 25
0
        public void Log(LoggingLevel level, object obj, Exception exception)
        {
            if (_level < level)
                return;

            LogInternal(level, obj, exception);
        }
Ejemplo n.º 26
0
 public void Log(LoggingLevel level, object obj)
 {
     _log.Log(GetNLogLevel(level), obj);
 }
		public void Log(LoggingLevel level, object obj) {
			throw new NotImplementedException();
		}
Ejemplo n.º 28
0
 public void Log(LoggingLevel level, LogWriterOutputProvider messageProvider)
 {
     _log.Log(GetNLogLevel(level), ToGenerator(messageProvider));
 }
		public void LogFormat(LoggingLevel level, IFormatProvider formatProvider, string format, params object[] args) {
			throw new NotImplementedException();
		}
Ejemplo n.º 30
0
 public void Log(LoggingLevel level, object obj, Exception exception)
 {
     if (level == LoggingLevel.Fatal)
     {
         Fatal(obj, exception);
     }
     else if (level == LoggingLevel.Error)
     {
         Error(obj, exception);
     }
     else if (level == LoggingLevel.Warn)
     {
         Warn(obj, exception);
     }
     else if (level == LoggingLevel.Info)
     {
         Info(obj, exception);
     }
     else if (level >= LoggingLevel.Debug)
     {
         Debug(obj, exception);
     }
 }
Ejemplo n.º 31
0
 public void LogFormat(LoggingLevel level, string format, params object[] args)
 {
     if (level == LoggingLevel.Fatal)
         FatalFormat(CultureInfo.InvariantCulture, format, args);
     else if (level == LoggingLevel.Error)
         ErrorFormat(CultureInfo.InvariantCulture, format, args);
     else if (level == LoggingLevel.Warn)
         WarnFormat(CultureInfo.InvariantCulture, format, args);
     else if (level == LoggingLevel.Info)
         InfoFormat(CultureInfo.InvariantCulture, format, args);
     else if (level >= LoggingLevel.Debug)
         DebugFormat(CultureInfo.InvariantCulture, format, args);
 }
Ejemplo n.º 32
0
 public void Log(LoggingLevel level, LogWriterOutputProvider messageProvider)
 {
     _logger.Write(TopshelfToSerilogLevel(level), ObjectMessageTemplate, new MessageProvider(messageProvider));
 }
Ejemplo n.º 33
0
 public void LogFormat(LoggingLevel level, IFormatProvider formatProvider, string format, params object[] args)
 {
     if (level == LoggingLevel.Fatal)
         FatalFormat(formatProvider, format, args);
     else if (level == LoggingLevel.Error)
         ErrorFormat(formatProvider, format, args);
     else if (level == LoggingLevel.Warn)
         WarnFormat(formatProvider, format, args);
     else if (level == LoggingLevel.Info)
         InfoFormat(formatProvider, format, args);
     else if (level >= LoggingLevel.Debug)
         DebugFormat(formatProvider, format, args);
 }
Ejemplo n.º 34
0
 public void Log(LoggingLevel level, object obj)
 {
     _log.Log(GetNLogLevel(level), obj);
 }
Ejemplo n.º 35
0
 public void Log(LoggingLevel level, object obj)
 {
     // no-op
 }
Ejemplo n.º 36
0
 public void Log(LoggingLevel level, LogWriterOutputProvider messageProvider)
 {
     _log.Log(GetNLogLevel(level), ToGenerator(messageProvider));
 }
Ejemplo n.º 37
0
 public void Log(LoggingLevel level, object obj, Exception exception)
 {
     // no-op
 }
Ejemplo n.º 38
0
        static LogLevel GetNLogLevel(LoggingLevel level)
        {
            if (level == LoggingLevel.Fatal)
                return LogLevel.Fatal;
            if (level == LoggingLevel.Error)
                return LogLevel.Error;
            if (level == LoggingLevel.Warn)
                return LogLevel.Warn;
            if (level == LoggingLevel.Info)
                return LogLevel.Info;
            if (level == LoggingLevel.Debug)
                return LogLevel.Debug;
            if (level == LoggingLevel.All)
                return LogLevel.Trace;

            return LogLevel.Off;
        }
Ejemplo n.º 39
0
 public void Log(LoggingLevel level, LogWriterOutputProvider messageProvider)
 {
     // no-op
 }
Ejemplo n.º 40
0
 /// <summary>
 /// Logs the format.
 /// </summary>
 /// <param name="level">The level.</param>
 /// <param name="format">The format.</param>
 /// <param name="args">The arguments.</param>
 public void LogFormat(LoggingLevel level, string format, params object[] args) => this.Log(level, new FormattedLogValues(format, args));
Ejemplo n.º 41
0
 public void LogFormat(LoggingLevel level, string format, params object[] args)
 {
     // no-op
 }
Ejemplo n.º 42
0
 /// <summary>
 /// Logs the specified level.
 /// </summary>
 /// <param name="level">The level.</param>
 /// <param name="obj">The object.</param>
 /// <param name="exception">The exception.</param>
 public void Log(LoggingLevel level, object obj, Exception exception) => this.logger.Log(ToLogLevel(level), 0, obj, exception, (s, e) => s.ToString());
Ejemplo n.º 43
0
 public TraceLogWriter(TraceSource source)
 {
     _source = source;
     _level  = LoggingLevel.FromSourceLevels(source.Switch.Level);
 }