org.slf4j.Logger#isDebugEnabled ( )源码实例Demo

下面列出了org.slf4j.Logger#isDebugEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jhipster-registry   文件: LoggingAspect.java
/**
 * Advice that logs when a method is entered and exited.
 *
 * @param joinPoint join point for advice.
 * @return result.
 * @throws Throwable throws {@link IllegalArgumentException}.
 */
@Around("applicationPackagePointcut() && springBeanPointcut()")
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
    Logger log = logger(joinPoint);
    if (log.isDebugEnabled()) {
        log.debug("Enter: {}() with argument[s] = {}", joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs()));
    }
    try {
        Object result = joinPoint.proceed();
        if (log.isDebugEnabled()) {
            log.debug("Exit: {}() with result = {}", joinPoint.getSignature().getName(), result);
        }
        return result;
    } catch (IllegalArgumentException e) {
        log.error("Illegal argument: {} in {}()", Arrays.toString(joinPoint.getArgs()), joinPoint.getSignature().getName());
        throw e;
    }
}
 
源代码2 项目: data-prep   文件: VariableLevelLog.java
/**
 * Check whether a SLF4J logger is enabled for a certain loglevel.
 * If the "logger" or the "level" is null, false is returned.
 */
public static boolean isEnabledFor(Logger logger, Level level) {
    boolean res = false;
    if (logger != null && level != null) {
        switch (level) {
        case TRACE:
            res = logger.isTraceEnabled();
            break;
        case DEBUG:
            res = logger.isDebugEnabled();
            break;
        case INFO:
            res = logger.isInfoEnabled();
            break;
        case WARN:
            res = logger.isWarnEnabled();
            break;
        case ERROR:
            res = logger.isErrorEnabled();
            break;
        }
    }
    return res;
}
 
源代码3 项目: glowroot   文件: DataSource.java
@VisibleForTesting
static void debug(Logger logger, String sql, @Nullable Object... args) {
    if (!logger.isDebugEnabled()) {
        return;
    }
    if (args.length == 0) {
        logger.debug(sql);
        return;
    }
    List<String> argStrings = Lists.newArrayList();
    for (Object arg : args) {
        if (arg instanceof String) {
            argStrings.add('\'' + (String) arg + '\'');
        } else if (arg == null) {
            argStrings.add("NULL");
        } else {
            argStrings.add(checkNotNull(arg.toString()));
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug("{} [{}]", sql, Joiner.on(", ").join(argStrings));
    }
}
 
源代码4 项目: brooklyn-server   文件: LoggingResourceFilter.java
private boolean isLogEnabled(Logger logger, LogLevel level) {
    switch (level) {
    case TRACE: return logger.isTraceEnabled();
    case DEBUG: return logger.isDebugEnabled();
    case INFO: return logger.isInfoEnabled();
    default: throw new IllegalStateException("Unexpected log level: "+level);
    }
}
 
源代码5 项目: spring-cache-self-refresh   文件: LoggingAspect.java
/**
 * Logs the entry to and exit from any method under the configured package.
 * 
 * @param joinPoint
 * @return
 */
public Object logAround(final ProceedingJoinPoint joinPoint) throws Throwable { // NOSONAR
	// No sonar comment is to skip sonar Throwable violation, which can not
	// be avoided
	Object ret = joinPoint.proceed();
	final Logger targetLogger = LoggingAspect.getLogger(joinPoint.getSourceLocation().getWithinType());
	if (targetLogger.isDebugEnabled()) {
		targetLogger.debug(LoggingAspect.METHOD_ARGS_RETURN, new String[] { joinPoint.getSignature().getName(),
				Arrays.toString(joinPoint.getArgs()), ret != null ? ret.toString() : null });
	}
	return ret;

}
 
源代码6 项目: x7   文件: LoggerProxy.java
public static void debug(Class clzz,  LogCallable callable) {
    Logger logger = loggerMap.get(clzz);
    if (logger == null )
        return;
    if (logger.isDebugEnabled()) {
        if (callable == null)
            return;
        String str = callable.call();
        if (StringUtil.isNullOrEmpty(str))
            return;
        logger.debug(str);
    }
}
 
源代码7 项目: arcusplatform   文件: RxIris.java
private static <T> void dolog(final LogLevel level, final Logger log, final String format, Object... value) {
   switch (level) {
   case TRACE:
      if (log.isTraceEnabled())
         log.trace(format, value);
      break;

   case DEBUG:
      if (log.isDebugEnabled())
         log.debug(format, value);
      break;

   case INFO:
      if (log.isInfoEnabled())
         log.info(format, value);
      break;

   case WARN:
      if (log.isWarnEnabled())
         log.warn(format, value);
      break;

   case ERROR:
      if (log.isErrorEnabled())
         log.error(format, value);
      break;

   default:
      break;
   }
}
 
源代码8 项目: rockscript   文件: ServerRequest.java
@Override
public void logBodyString(String bodyString, Logger log) {
  if (log.isDebugEnabled()) {
    if (bodyString!=null) {
      BufferedReader reader = new BufferedReader(new StringReader(bodyString));
      reader.lines().forEach(line->log.debug("  "+line));
    } else {
      log.debug("  ---body-is-null---");
    }
  }
}
 
源代码9 项目: nmonvisualizer   文件: DataHelper.java
public static void aggregateProcessData(ProcessDataSet data, Logger logger) {
    long start = System.nanoTime();
    Map<String, List<Process>> processNameToProcesses = DataHelper.getProcessesByName(data, false);

    for (List<Process> processes : processNameToProcesses.values()) {
        if (processes.size() > 1) {
            aggregateProcesses(data, processes, logger);
        }
    }

    if (logger.isDebugEnabled()) {
        logger.debug("Aggregated process data for {} in {}ms ", data, (System.nanoTime() - start) / 1000000.0d);
    }
}
 
源代码10 项目: aries-jax-rs-whiteboard   文件: LogUtils.java
public static Consumer<Object> ifDebugEnabled(
    Logger log, Supplier<String> message) {

    return o -> {
        if (log.isDebugEnabled()) {
            log.debug(message.get(), o);
        }
    };
}
 
源代码11 项目: cosmic   文件: Journal.java
public void record(final Logger logger, final String msg, final Object... params) {
    if (logger.isDebugEnabled()) {
        final StringBuilder buf = new StringBuilder();
        toString(buf, msg, params);
        final String entry = buf.toString();
        log(entry);
        logger.debug(entry);
    } else {
        log(msg, params);
    }
}
 
源代码12 项目: legstar-core2   文件: RecognizerErrorHandler.java
/**
 * Format an error message as expected by ANTLR. It is basically the
 * same error message that ANTL BaseRecognizer generates with some
 * additional data.
 * Also used to log debugging information.
 * @param log the logger to use at debug time
 * @param recognizer the lexer or parser who generated the error
 * @param e the exception that occured
 * @param superMessage the error message that the super class generated
 * @param tokenNames list of token names
 * @return a formatted error message
 */
public static String getErrorMessage(
        final Logger log,
        final BaseRecognizer recognizer,
        final RecognitionException e,
        final String superMessage,
        final String[] tokenNames) {
    if (log.isDebugEnabled()) {
        List < ? > stack = BaseRecognizer.getRuleInvocationStack(
                e, recognizer.getClass().getSuperclass().getName());
        String debugMsg = recognizer.getErrorHeader(e)
            + " " + e.getClass().getSimpleName()
            + ": " + superMessage
            + ":";
        if (e instanceof NoViableAltException) {
            NoViableAltException nvae = (NoViableAltException) e;
            debugMsg += " (decision=" + nvae.decisionNumber
            + " state=" + nvae.stateNumber + ")"
            + " decision=<<" + nvae.grammarDecisionDescription + ">>";
        } else if (e instanceof UnwantedTokenException) {
            UnwantedTokenException ute = (UnwantedTokenException) e;
            debugMsg += " (unexpected token=" + toString(ute.getUnexpectedToken(), tokenNames) + ")";

        } else if (e instanceof EarlyExitException) {
            EarlyExitException eea = (EarlyExitException) e;
            debugMsg += " (decision=" + eea.decisionNumber + ")";
        }
        debugMsg += " ruleStack=" + stack.toString();
        log.debug(debugMsg);
    }

    return makeUserMsg(e, superMessage);
}
 
源代码13 项目: sftp-fs   文件: SFTPLogger.java
public static void createdInputStream(Logger logger, String channelId, String path) {
    if (logger != null && logger.isDebugEnabled()) {
        logger.debug(String.format(getMessage("log.createdInputStream"), channelId, path)); //$NON-NLS-1$
    }
}
 
源代码14 项目: tankbattle   文件: LogUtils.java
public static void debug(String message) {
    Logger log = getLogger(getClassName());
    if (log.isDebugEnabled()) {
        log.debug(message);
    }
}
 
源代码15 项目: sftp-fs   文件: SFTPLogger.java
public static void failedToCreatePool(Logger logger, IOException e) {
    if (logger != null && logger.isDebugEnabled()) {
        logger.debug(getMessage("log.failedToCreatePool"), e); //$NON-NLS-1$
    }
}
 
源代码16 项目: google-ads-java   文件: RequestLogger.java
private static boolean isLevelEnabled(Level logLevel, Logger logger) {
  return (logLevel == Level.INFO && logger.isInfoEnabled())
      || (logLevel == Level.WARN && logger.isWarnEnabled())
      || (logLevel == Level.DEBUG && logger.isDebugEnabled());
}
 
源代码17 项目: AsuraFramework   文件: SimpleSemaphore.java
/**
 * Grants a lock on the identified resource to the calling thread (blocking
 * until it is available).
 * 
 * @return true if the lock was obtained.
 */
public synchronized boolean obtainLock(Connection conn, String lockName) {

    lockName = lockName.intern();

    Logger log = getLog();

    if(log.isDebugEnabled()) {
        log.debug(
            "Lock '" + lockName + "' is desired by: "
                    + Thread.currentThread().getName());
    }

    if (!isLockOwner(conn, lockName)) {
        if(log.isDebugEnabled()) {
            log.debug(
                "Lock '" + lockName + "' is being obtained: "
                        + Thread.currentThread().getName());
        }
        while (locks.contains(lockName)) {
            try {
                this.wait();
            } catch (InterruptedException ie) {
                if(log.isDebugEnabled()) {
                    log.debug(
                        "Lock '" + lockName + "' was not obtained by: "
                                + Thread.currentThread().getName());
                }
            }
        }

        if(log.isDebugEnabled()) {
            log.debug(
                "Lock '" + lockName + "' given to: "
                        + Thread.currentThread().getName());
        }
        getThreadLocks().add(lockName);
        locks.add(lockName);
    } else if(log.isDebugEnabled()) {
        log.debug(
            "Lock '" + lockName + "' already owned by: "
                    + Thread.currentThread().getName()
                    + " -- but not owner!",
            new Exception("stack-trace of wrongful returner"));
    }

    return true;
}
 
源代码18 项目: sftp-fs   文件: SFTPLogger.java
public static void closedOutputStream(Logger logger, String channelId, String path) {
    if (logger != null && logger.isDebugEnabled()) {
        logger.debug(String.format(getMessage("log.closedOutputStream"), channelId, path)); //$NON-NLS-1$
    }
}
 
源代码19 项目: dremio-oss   文件: PrelTransformer.java
public static void log(final SqlHandlerConfig config, final String name, final PhysicalPlan plan, final Logger logger) throws JsonProcessingException {
  if (logger.isDebugEnabled()) {
    String planText = plan.unparse(config.getContext().getLpPersistence().getMapper().writer());
    logger.debug(name + " : \n" + planText);
  }
}
 
源代码20 项目: ph-commons   文件: ScopeHelper.java
/**
 * This is a just a helper method to determine whether request scope
 * creation/deletion issues should be logged or not.
 *
 * @param aLogger
 *        The logger to check.
 * @return <code>true</code> if request scope creation/deletion should be
 *         logged, <code>false</code> otherwise.
 */
public static boolean debugRequestScopeLifeCycle (@Nonnull final Logger aLogger)
{
  // Also debug scopes, if debug logging is enabled
  if (aLogger.isDebugEnabled ())
    return true;

  return (isLifeCycleDebuggingEnabled () || isDebugRequestScopeEnabled ()) && aLogger.isInfoEnabled ();
}