示例#1
0
文件: Provider.cs 项目: daitkar/CFM
            private bool LogException(LogLevel logLevel, Func <string> messageFunc, Exception exception)
            {
                switch (logLevel)
                {
                case LogLevel.Debug:
                    if (logger.IsDebugEnabled)
                    {
                        logger.Debug(exception, messageFunc());
                        return(true);
                    }
                    break;

                case LogLevel.Info:
                    if (logger.IsInfoEnabled)
                    {
                        logger.Info(exception, messageFunc());
                        return(true);
                    }
                    break;

                case LogLevel.Warn:
                    if (logger.IsWarnEnabled)
                    {
                        logger.Warn(exception, messageFunc());
                        return(true);
                    }
                    break;

                case LogLevel.Error:
                    if (logger.IsErrorEnabled)
                    {
                        logger.Error(exception, messageFunc());
                        return(true);
                    }
                    break;

                case LogLevel.Fatal:
                    if (logger.IsFatalEnabled)
                    {
                        logger.Fatal(exception, messageFunc());
                        return(true);
                    }
                    break;

                default:
                    if (logger.IsTraceEnabled)
                    {
                        logger.Trace(exception, messageFunc());
                        return(true);
                    }
                    break;
                }
                return(false);
            }
示例#2
0
文件: Provider.cs 项目: daitkar/CFM
            private bool IsLogLevelEnable(LogLevel logLevel)
            {
                switch (logLevel)
                {
                case LogLevel.Debug:
                    return(logger.IsDebugEnabled);

                case LogLevel.Info:
                    return(logger.IsInfoEnabled);

                case LogLevel.Warn:
                    return(logger.IsWarnEnabled);

                case LogLevel.Error:
                    return(logger.IsErrorEnabled);

                case LogLevel.Fatal:
                    return(logger.IsFatalEnabled);

                default:
                    return(logger.IsTraceEnabled);
                }
            }
示例#3
0
文件: Provider.cs 项目: daitkar/CFM
            public bool Log(LogLevel logLevel, Func <string> messageFunc, Exception exception, params object[] formatParameters)
            {
                if (messageFunc == null)
                {
                    return(IsLogLevelEnable(logLevel));
                }
                messageFunc = LogMessageFormatter.SimulateStructuredLogging(messageFunc, formatParameters);

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

                case LogLevel.Info:
                    if (logger.IsInfoEnabled)
                    {
                        logger.Info(messageFunc());
                        return(true);
                    }
                    break;

                case LogLevel.Warn:
                    if (logger.IsWarnEnabled)
                    {
                        logger.Warn(messageFunc());
                        return(true);
                    }
                    break;

                case LogLevel.Error:
                    if (logger.IsErrorEnabled)
                    {
                        logger.Error(messageFunc());
                        return(true);
                    }
                    break;

                case LogLevel.Fatal:
                    if (logger.IsFatalEnabled)
                    {
                        logger.Fatal(messageFunc());
                        return(true);
                    }
                    break;

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