public static void Log(MpdLogLevelEnum level, int ignoreStackFrameCount, params object[] args) { StackTrace st = new StackTrace(true); ignoreStackFrameCount++; ILog logger = GetLogger(st, ignoreStackFrameCount); if (!CanLog(logger, level)) { return; } StringBuilder msgBuilder = new StringBuilder(); CreateCallerMessage(msgBuilder, st, ignoreStackFrameCount); ProcessArguments(msgBuilder, args); switch (level) { case MpdLogLevelEnum.Debug: logger.Debug(msgBuilder.ToString()); break; case MpdLogLevelEnum.Error: logger.Error(msgBuilder.ToString()); break; case MpdLogLevelEnum.Info: logger.Info(msgBuilder.ToString()); break; case MpdLogLevelEnum.Warn: logger.Warn(msgBuilder.ToString()); break; } }
private static bool CanLog(ILog logger, MpdLogLevelEnum level) { switch (level) { case MpdLogLevelEnum.Debug: return(logger.IsDebugEnabled); case MpdLogLevelEnum.Error: return(logger.IsErrorEnabled || logger.IsFatalEnabled || logger.IsDebugEnabled || logger.IsInfoEnabled || logger.IsWarnEnabled); case MpdLogLevelEnum.Info: return(logger.IsDebugEnabled || logger.IsInfoEnabled); case MpdLogLevelEnum.Warn: return(logger.IsDebugEnabled || logger.IsInfoEnabled || logger.IsWarnEnabled); } return(false); }
public static void Log(MpdLogLevelEnum level, params object[] args) { Log(level, 1, args); }