Example usage for org.apache.commons.logging Log isDebugEnabled

List of usage examples for org.apache.commons.logging Log isDebugEnabled

Introduction

In this page you can find the example usage for org.apache.commons.logging Log isDebugEnabled.

Prototype

boolean isDebugEnabled();

Source Link

Document

Is debug logging currently enabled?

Usage

From source file:com.headissue.pigeon.util.LogUtils.java

public static void debug(Log log, Throwable t, String message, Object... args) {
    if (log.isDebugEnabled()) {
        if (args != null && args.length > 0) {
            message = String.format(message, args);
        }// w  w w  . j a  v a  2 s  .c  o m
        log.debug(message, t);
    }
}

From source file:com.rsmart.rfabric.logging.FormattedLogger.java

/**
 * Wraps {@link Log#debug(String)}//w ww .j a v  a 2 s. com
 * 
 * @param pattern to format against
 * @param objs an array of objects used as parameters to the <code>pattern</code>
 */
public static final void debug(String pattern, Object... objs) {
    Log log = getLog();
    if (log.isDebugEnabled()) {
        log.debug(getMessage(pattern, objs));
    }
}

From source file:com.oncore.calorders.core.utils.Logger.java

/**
 * Writes a debug log entry if debugging is enabled
 *
 * @author OnCore Consulting LLC//from w ww. ja  va 2 s. com
 *
 * @param log a handle to the log
 * @param message the text to log
 */
public static void debug(final Log log, final String message) {
    if (log != null && message != null) {
        if (log.isDebugEnabled()) {
            log.debug(message);
        }

    }
}

From source file:com.buffalokiwi.api.APILog.java

/**
 * Log a message with debug log level.// w w  w .j ava 2  s.c om
 *
 * @param message log this message
 */
public static void debug(final Log log, final Object... message) {
    if (log.isDebugEnabled())
        log.debug(concat(message));
}

From source file:framework.retrieval.engine.common.RetrievalUtil.java

public static void debugLog(Log log, Object msg) {
    if (log.isDebugEnabled()) {
        log.debug(msg);
    }
}

From source file:com.buffalokiwi.api.APILog.java

/**
 * Log an error with debug log level./* w w w.  j a  va  2 s. c  o m*/
 *
 * @param log Log to write to
 * @param message log this message
 * @param t log this cause
 */
public static void debug(final Log log, final Throwable t, final Object... message) {
    if (log.isDebugEnabled())
        log.debug(concat(message), t);
}

From source file:com.moss.error_reporting.client.ErrorReportProxyFactory.java

private static ProxyFactory create(ProxyProviderOption option, ProxyProviderOption defaultOption) {

    Log log = LogFactory.getLog(ErrorReportProxyFactory.class);

    if (option == null) {

        if (log.isDebugEnabled()) {
            log.debug(//  w  w w. j  a v a 2 s  . c o  m
                    "No option was provided as an argument, attempting to determine option from system property '"
                            + PROXY_PROVIDER_PROPERTY + "'");
        }

        try {
            String prop = System.getProperty(PROXY_PROVIDER_PROPERTY);
            if (prop != null) {
                option = ProxyProviderOption.valueOf(prop.toUpperCase());

                if (option == null) {
                    if (log.isDebugEnabled()) {
                        log.debug("Could not determine option from system property '" + PROXY_PROVIDER_PROPERTY
                                + "': " + prop);
                    }
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Determined option from system property '" + PROXY_PROVIDER_PROPERTY + "': "
                                + option);
                    }
                }
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("The system property '" + PROXY_PROVIDER_PROPERTY
                            + "' was not set, cannot use it to determine which option to use.");
                }
            }
        } catch (Exception ex) {
            log.warn(
                    "Encountered unexpected failure while attempting to determine which option to use from system property '"
                            + PROXY_PROVIDER_PROPERTY + "'",
                    ex);
        }

        if (option == null) {
            if (defaultOption == null) {
                throw new RuntimeException(
                        "No default option was provided, cannot determine which option to use for supplying the proxy provider.");
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("No specific option was chosen, using default option: " + defaultOption);
                }
                option = defaultOption;
            }
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Option " + option + " was provided as an argument, using it directly.");
        }
    }

    ProxyProvider prov = option.makeProvider();
    ProxyFactory factory = new ProxyFactory(prov);

    return factory;
}

From source file:com.moss.identity.veracity.VeracityProxyFactory.java

private static ProxyFactory create(ProxyProviderOption option, ProxyProviderOption defaultOption) {

    Log log = LogFactory.getLog(VeracityProxyFactory.class);

    if (option == null) {

        if (log.isDebugEnabled()) {
            log.debug(/*w  w  w . ja  va 2s.com*/
                    "No option was provided as an argument, attempting to determine option from system property '"
                            + PROXY_PROVIDER_PROPERTY + "'");
        }

        try {
            String prop = System.getProperty(PROXY_PROVIDER_PROPERTY);
            if (prop != null) {
                option = ProxyProviderOption.valueOf(prop.toUpperCase());

                if (option == null) {
                    if (log.isDebugEnabled()) {
                        log.debug("Could not determine option from system property '" + PROXY_PROVIDER_PROPERTY
                                + "': " + prop);
                    }
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Determined option from system property '" + PROXY_PROVIDER_PROPERTY + "': "
                                + option);
                    }
                }
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("The system property '" + PROXY_PROVIDER_PROPERTY
                            + "' was not set, cannot use it to determine which option to use.");
                }
            }
        } catch (Exception ex) {
            log.warn(
                    "Encountered unexpected failure while attempting to determine which option to use from system property '"
                            + PROXY_PROVIDER_PROPERTY + "'",
                    ex);
        }

        if (option == null) {
            if (defaultOption == null) {
                throw new RuntimeException(
                        "No default option was provided, cannot determine which option to use for supplying the proxy provider.");
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("No specific option was chosen, using default option: " + defaultOption);
                }
                option = defaultOption;
            }
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Option " + option + " was provided as an argument, using it directly.");
        }
    }

    ProxyProvider prov = option.makeProvider();
    ProxyFactory factory = new ProxyFactory(prov);

    return factory;
}

From source file:com.moss.error_reporting.server.TestErrorReportProxyFactory.java

private static ProxyFactory create(ProxyProviderOption option, ProxyProviderOption defaultOption) {

    Log log = LogFactory.getLog(TestErrorReportProxyFactory.class);

    if (option == null) {

        if (log.isDebugEnabled()) {
            log.debug(/* w  w w  .j  a va  2  s .  c  o  m*/
                    "No option was provided as an argument, attempting to determine option from system property '"
                            + PROXY_PROVIDER_PROPERTY + "'");
        }

        try {
            String prop = System.getProperty(PROXY_PROVIDER_PROPERTY);
            if (prop != null) {
                option = ProxyProviderOption.valueOf(prop.toUpperCase());

                if (option == null) {
                    if (log.isDebugEnabled()) {
                        log.debug("Could not determine option from system property '" + PROXY_PROVIDER_PROPERTY
                                + "': " + prop);
                    }
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Determined option from system property '" + PROXY_PROVIDER_PROPERTY + "': "
                                + option);
                    }
                }
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("The system property '" + PROXY_PROVIDER_PROPERTY
                            + "' was not set, cannot use it to determine which option to use.");
                }
            }
        } catch (Exception ex) {
            log.warn(
                    "Encountered unexpected failure while attempting to determine which option to use from system property '"
                            + PROXY_PROVIDER_PROPERTY + "'",
                    ex);
        }

        if (option == null) {
            if (defaultOption == null) {
                throw new RuntimeException(
                        "No default option was provided, cannot determine which option to use for supplying the proxy provider.");
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("No specific option was chosen, using default option: " + defaultOption);
                }
                option = defaultOption;
            }
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Option " + option + " was provided as an argument, using it directly.");
        }
    }

    ProxyProvider prov = option.makeProvider();
    ProxyFactory factory = new ProxyFactory(prov);

    return factory;
}

From source file:com.legstar.cobol.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.//from  w  w  w.  j  a  v a  2s.c om
 * 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 Log 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);
}