private static Logging.LogLevel?MapLogLevel(LogLevel loglevel)
        {
            if (loglevel == LogLevel.Fatal)
            {
                return(Logging.LogLevel.Fatal);
            }
            if (loglevel == LogLevel.Error)
            {
                return(Logging.LogLevel.Error);
            }
            if (loglevel == LogLevel.Warn)
            {
                return(Logging.LogLevel.Warn);
            }
            if (loglevel == LogLevel.Info)
            {
                return(Logging.LogLevel.Info);
            }
            if (loglevel == LogLevel.Debug)
            {
                return(Logging.LogLevel.Debug);
            }
            if (loglevel == LogLevel.All)
            {
                return(Logging.LogLevel.Trace);
            }

            // Masstransit supports LogLevel None, which is not supported by LibLog
            // We return null, so the log methods can check for null and decide not to log anything
            return(null);
        }
Example #2
0
        NLog.LogLevel GetNLogLevel(MassTransit.Logging.LogLevel level)
        {
            if (level == MassTransit.Logging.LogLevel.Fatal)
            {
                return(NLog.LogLevel.Fatal);
            }
            if (level == MassTransit.Logging.LogLevel.Error)
            {
                return(NLog.LogLevel.Error);
            }
            if (level == MassTransit.Logging.LogLevel.Warn)
            {
                return(NLog.LogLevel.Warn);
            }
            if (level == MassTransit.Logging.LogLevel.Info)
            {
                return(NLog.LogLevel.Info);
            }
            if (level == MassTransit.Logging.LogLevel.Debug)
            {
                return(NLog.LogLevel.Debug);
            }
            if (level == MassTransit.Logging.LogLevel.All)
            {
                return(NLog.LogLevel.Trace);
            }

            return(NLog.LogLevel.Off);
        }
        public void Log(LogLevel level, object obj)
        {
            // Map masstransit 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));
        }
        public void Log(LogLevel level, object obj, Exception exception)
        {
            // If exception is null, use log method without exception
            if (exception == null)
            {
                Log(level, obj);
                return;
            }

            // Map masstransit 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);
        }
 public void Log(LogLevel level, LogOutputProvider messageProvider)
 {
     WriteSerilog(GetSerilogLevel(level), messageProvider);
 }
 public void Log(LogLevel level, object obj, Exception exception)
 {
     WriteSerilog(GetSerilogLevel(level), exception, obj);
 }
 public void Log(LogLevel level, object obj)
 {
     WriteSerilog(GetSerilogLevel(level), obj);
 }
        private LogEventLevel GetSerilogLevel(LogLevel level)
        {
            LogEventLevel logEventLevel;

            return LogLevelTypeMap.TryGetValue(level, out logEventLevel) ? logEventLevel : LogEventLevel.Information;
        }
Example #9
0
 public void LogFormat(LogLevel level, string format, params object[] args)
 {
     if (level == LogLevel.Fatal)
         FatalFormat(CultureInfo.InvariantCulture, format, args);
     else if (level == LogLevel.Error)
         ErrorFormat(CultureInfo.InvariantCulture, format, args);
     else if (level == LogLevel.Warn)
         WarnFormat(CultureInfo.InvariantCulture, format, args);
     else if (level == LogLevel.Info)
         InfoFormat(CultureInfo.InvariantCulture, format, args);
     else if (level >= LogLevel.Debug)
         DebugFormat(CultureInfo.InvariantCulture, format, args);
 }
Example #10
0
 public void Log(LogLevel level, object obj, Exception exception)
 {
     if (level == LogLevel.Fatal)
         Fatal(obj, exception);
     else if (level == LogLevel.Error)
         Error(obj, exception);
     else if (level == LogLevel.Warn)
         Warn(obj, exception);
     else if (level == LogLevel.Info)
         Info(obj, exception);
     else if (level >= LogLevel.Debug)
         Debug(obj, exception);
 }
Example #11
0
 public void Log(MassTransit.Logging.LogLevel level, object obj)
 {
     _log.Log(GetNLogLevel(level), obj);
 }
 public void LogFormat(LogLevel level, string format, params object[] args)
 {
     Log(level, string.Format(format, args));
 }
 public void Log(LogLevel level, LogOutputProvider messageProvider)
 {
     Log(level, messageProvider());
 }
 public void LogFormat(LogLevel level, string format, params object[] args)
 {
     WriteSerilog(GetSerilogLevel(level), format, args);
 }
Example #15
0
 public void Log(MassTransit.Logging.LogLevel level, object obj, Exception exception)
 {
     _log.Log(GetNLogLevel(level), obj == null ? "" : obj.ToString(), exception);
 }
        private LogEventLevel GetSerilogLevel(LogLevel level)
        {
            if (level == LogLevel.Fatal)
            {
                return LogEventLevel.Fatal;
            }
            if (level == LogLevel.Error)
            {
                return LogEventLevel.Error;
            }
            if (level == LogLevel.Warn)
            {
                return LogEventLevel.Warning;
            }
            if (level == LogLevel.Info)
            {
                return LogEventLevel.Information;
            }
            if (level == LogLevel.Debug)
            {
                return LogEventLevel.Debug;
            }
            if (level == LogLevel.All)
            {
                return LogEventLevel.Verbose;
            }

            return LogEventLevel.Information;
        }
Example #17
0
 public void Log(MassTransit.Logging.LogLevel level, LogOutputProvider messageProvider)
 {
     _log.Log(GetNLogLevel(level), ToGenerator(messageProvider));
 }
Example #18
0
 public void Log(LogLevel level, LogOutputProvider messageProvider)
 {
     if (level == LogLevel.Fatal)
         Fatal(messageProvider);
     else if (level == LogLevel.Error)
         Error(messageProvider);
     else if (level == LogLevel.Warn)
         Warn(messageProvider);
     else if (level == LogLevel.Info)
         Info(messageProvider);
     else if (level >= LogLevel.Debug)
         Debug(messageProvider);
 }
Example #19
0
 public void LogFormat(MassTransit.Logging.LogLevel level, string format, params object[] args)
 {
     _log.Log(GetNLogLevel(level), format, args);
 }
Example #20
0
 public void LogFormat(LogLevel level, IFormatProvider formatProvider, string format, params object[] args)
 {
     if (level == LogLevel.Fatal)
         FatalFormat(formatProvider, format, args);
     else if (level == LogLevel.Error)
         ErrorFormat(formatProvider, format, args);
     else if (level == LogLevel.Warn)
         WarnFormat(formatProvider, format, args);
     else if (level == LogLevel.Info)
         InfoFormat(formatProvider, format, args);
     else if (level >= LogLevel.Debug)
         DebugFormat(formatProvider, format, args);
 }
Example #21
0
 public void Log(MassTransit.Logging.LogLevel level, object obj, Exception exception)
 {
     _log.Log(GetNLogLevel(level), exception, obj?.ToString() ?? "");
 }