Пример #1
0
            public bool Log(MvxLogLevel logLevel, Func <string> messageFunc, Exception exception,
                            params object[] formatParameters)
            {
                if (messageFunc == null)
                {
                    return(true);
                }

                messageFunc = LogMessageFormatter.SimulateStructuredLogging(messageFunc, formatParameters);

                Write(logLevel, messageFunc(), exception);
                return(true);
            }
Пример #2
0
            public bool Log(MvxLogLevel logLevel, Func <string> messageFunc, Exception exception, params object[] formatParameters)
            {
                if (messageFunc == null)
                {
                    //nothing to log..
                    return(true);
                }

                messageFunc = LogMessageFormatter.SimulateStructuredLogging(messageFunc, formatParameters);

                _logWriteDelegate(ToLogMessageSeverity(logLevel), LogSystem, _skipLevel, exception, true, 0, null,
                                  _category, null, messageFunc.Invoke());

                return(true);
            }
Пример #3
0
            public bool Log(MvxLogLevel logLevel, Func <string> messageFunc, Exception exception, params object[] formatParameters)
            {
                var severity = MapSeverity(logLevel);

                if (messageFunc == null)
                {
                    return(_shouldLog(_loggerName, severity));
                }


                messageFunc = LogMessageFormatter.SimulateStructuredLogging(messageFunc, formatParameters);
                if (exception != null)
                {
                    return(LogException(logLevel, messageFunc, exception));
                }
                _writeLog(_loggerName, messageFunc(), severity);
                return(true);
            }
Пример #4
0
            public bool Log(MvxLogLevel logLevel, Func <string> messageFunc, Exception exception, params object[] formatParameters)
            {
                if (messageFunc == null)
                {
                    return(IsLogLevelEnable(logLevel));
                }
                messageFunc = LogMessageFormatter.SimulateStructuredLogging(messageFunc, formatParameters);

                if (_logEventInfoFact != null)
                {
                    if (IsLogLevelEnable(logLevel))
                    {
                        var nlogLevel = TranslateLevel(logLevel);
                        _logger.Log(_logEventInfoFact(_logger.Name, nlogLevel, messageFunc(), exception));
                        return(true);
                    }
                    return(false);
                }

                if (exception != null)
                {
                    return(LogException(logLevel, messageFunc, exception));
                }
                switch (logLevel)
                {
                case MvxLogLevel.Debug:
                    if (_logger.IsDebugEnabled)
                    {
                        _logger.Debug(messageFunc());
                        return(true);
                    }
                    break;

                case MvxLogLevel.Info:
                    if (_logger.IsInfoEnabled)
                    {
                        _logger.Info(messageFunc());
                        return(true);
                    }
                    break;

                case MvxLogLevel.Warn:
                    if (_logger.IsWarnEnabled)
                    {
                        _logger.Warn(messageFunc());
                        return(true);
                    }
                    break;

                case MvxLogLevel.Error:
                    if (_logger.IsErrorEnabled)
                    {
                        _logger.Error(messageFunc());
                        return(true);
                    }
                    break;

                case MvxLogLevel.Fatal:
                    if (_logger.IsFatalEnabled)
                    {
                        _logger.Fatal(messageFunc());
                        return(true);
                    }
                    break;

                default:
                    if (_logger.IsTraceEnabled)
                    {
                        _logger.Trace(messageFunc());
                        return(true);
                    }
                    break;
                }
                return(false);
            }