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

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

Introduction

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

Prototype

void debug(Object message);

Source Link

Document

Logs a message with debug log level.

Usage

From source file:com.taobao.tddl.common.DynamicLog.java

public void debug(String key, Object[] args, String defaultLog, Log log) {
    String content = build(key, args, defaultLog);
    if (content != null && !"".equals(content)) {
        log.debug(content);
    }/* www  . j  a v  a2 s .  c  om*/
}

From source file:com.picocontainer.gems.monitors.CommonsLoggingComponentMonitor.java

/** {@inheritDoc} **/
public void invoked(final PicoContainer container, final ComponentAdapter<?> componentAdapter,
        final Member member, final Object instance, final long duration, final Object retVal,
        final Object... args) {
    Log log = getLog(member);
    if (log.isDebugEnabled()) {
        log.debug(ComponentMonitorHelper.format(ComponentMonitorHelper.INVOKED, memberToString(member),
                instance, duration));/*from  w w  w. j  a v a 2 s  .  c  o m*/
    }
    delegate.invoked(container, componentAdapter, member, instance, duration, retVal, args);
}

From source file:com.picocontainer.gems.monitors.CommonsLoggingComponentMonitor.java

/** {@inheritDoc} **/
public <T> Constructor<T> instantiating(final PicoContainer container,
        final ComponentAdapter<T> componentAdapter, final Constructor<T> constructor) {
    Log log = getLog(constructor);
    if (log.isDebugEnabled()) {
        log.debug(
                ComponentMonitorHelper.format(ComponentMonitorHelper.INSTANTIATING, ctorToString(constructor)));
    }/*  ww  w.j a v a  2s .  c  om*/
    return delegate.instantiating(container, componentAdapter, constructor);
}

From source file:com.picocontainer.gems.monitors.CommonsLoggingComponentMonitor.java

/** {@inheritDoc} **/
public <T> void instantiated(final PicoContainer container, final ComponentAdapter<T> componentAdapter,
        final Constructor<T> constructor, final Object instantiated, final Object[] parameters,
        final long duration) {
    Log log = getLog(constructor);
    if (log.isDebugEnabled()) {
        log.debug(ComponentMonitorHelper.format(ComponentMonitorHelper.INSTANTIATED, ctorToString(constructor),
                duration, instantiated != null ? instantiated.getClass().getName() : " null ",
                parmsToString(parameters)));
    }/*from   w w  w .  ja v  a  2s.co  m*/
    delegate.instantiated(container, componentAdapter, constructor, instantiated, parameters, duration);
}

From source file:mockit.integration.logging.LoggingIntegrationsTest.java

@Test
public void commonsLoggingShouldLogNothing() {
    Log log1 = LogFactory.getLog("test");
    Log log2 = LogFactory.getLog(LoggingIntegrationsTest.class);

    assertFalse(log1.isTraceEnabled());/*from w  ww  .  j a v  a  2  s .  co m*/
    log1.error("testing that log does nothing");
    assertFalse(log1.isDebugEnabled());
    log2.trace("test");
    log2.debug("testing that log does nothing");
}

From source file:dk.statsbiblioteket.util.Logs.java

/**
 * Log the message and the elements to the log at the specified level.
 * Elements are converted to Strings and appended to the message. Arrays,
 * Lists and similar in the elements are expanded to a certain degree of
 * detail./*from  w  ww.  ja v  a2  s  .c o m*/
 *
 * Sample input/output:
 * <code>log(myLog, Level.TRACE, false, "Started test", null,
 * 5, new String[]{"flim", "flam"});</code>
 * expands to
 * <code>log.trace("Started test (5, (flim, flam))");</code>
 *
 * @param log      the log to log to.
 * @param level    the level to log to (e.g. TRACE, DEBUG, INFO...).
 * @param verbose  if true, the elements are expanded more than for false.
 * @param error    the cause of this logging. If null, no cause is logged.
 * @param message  the message for the log.
 * @param elements the elements to log.
 */
public static void log(Log log, Level level, String message, Throwable error, boolean verbose,
        Object... elements) {
    int maxLength = verbose ? VERBOSE_MAXLENGTH : DEFAULT_MAXLENGTH;
    int maxDepth = verbose ? VERBOSE_MAXDEPTH : DEFAULT_MAXDEPTH;
    String expanded = message;
    if (elements != null && elements.length > 0) {
        expanded += expand(elements, maxLength, maxDepth);
    }
    switch (level) {
    case TRACE:
        if (!log.isTraceEnabled()) {
            return;
        }
        if (error == null) {
            log.trace(expanded);
        } else {
            log.trace(expanded, error);
        }
        break;
    case DEBUG:
        if (!log.isDebugEnabled()) {
            return;
        }
        if (error == null) {
            log.debug(expanded);
        } else {
            log.debug(expanded, error);
        }
        break;
    case INFO:
        if (!log.isInfoEnabled()) {
            return;
        }
        if (error == null) {
            log.info(expanded);
        } else {
            log.info(expanded, error);
        }
        break;
    case WARN:
        if (!log.isWarnEnabled()) {
            return;
        }
        if (error == null) {
            log.warn(expanded);
        } else {
            log.warn(expanded, error);
        }
        break;
    case ERROR:
        if (!log.isErrorEnabled()) {
            return;
        }
        if (error == null) {
            log.error(expanded);
        } else {
            log.error(expanded, error);
        }
        break;
    case FATAL:
        if (!log.isFatalEnabled()) {
            return;
        }
        if (error == null) {
            log.fatal(expanded);
        } else {
            log.fatal(expanded, error);
        }
        break;
    default:
        throw new IllegalArgumentException("The level '" + level + "' is unknown");
    }
}

From source file:com.amazon.carbonado.repo.tupl.LogEventListener.java

@Override
public void notify(EventType type, String message, Object... args) {
    int intLevel = type.level.intValue();

    Log log = mLog;
    if (log != null) {
        if (intLevel <= Level.INFO.intValue()) {
            if (type.category == EventType.Category.CHECKPOINT) {
                if (log.isDebugEnabled()) {
                    log.debug(format(type, message, args));
                }//from   w w w  . ja v  a2s .  c o m
            } else if (log.isInfoEnabled()) {
                log.info(format(type, message, args));
            }
        } else if (intLevel <= Level.WARNING.intValue()) {
            if (log.isWarnEnabled()) {
                log.warn(format(type, message, args));
            }
        } else if (intLevel <= Level.SEVERE.intValue()) {
            if (log.isFatalEnabled()) {
                log.fatal(format(type, message, args));
            }
        }
    }

    if (intLevel > Level.WARNING.intValue() && mPanicHandler != null) {
        mPanicHandler.onPanic(mDatabase, type, message, args);
    }
}

From source file:javadz.beanutils.MethodUtils.java

/**
 * Gets the class for the primitive type corresponding to the primitive wrapper class given.
 * For example, an instance of <code>Boolean.class</code> returns a <code>boolean.class</code>. 
 * @param wrapperType the /*from   ww  w . j a va2 s.  co m*/
 * @return the primitive type class corresponding to the given wrapper class,
 * null if no match is found
 */
public static Class getPrimitiveType(Class wrapperType) {
    // does anyone know a better strategy than comparing names?
    if (Boolean.class.equals(wrapperType)) {
        return boolean.class;
    } else if (Float.class.equals(wrapperType)) {
        return float.class;
    } else if (Long.class.equals(wrapperType)) {
        return long.class;
    } else if (Integer.class.equals(wrapperType)) {
        return int.class;
    } else if (Short.class.equals(wrapperType)) {
        return short.class;
    } else if (Byte.class.equals(wrapperType)) {
        return byte.class;
    } else if (Double.class.equals(wrapperType)) {
        return double.class;
    } else if (Character.class.equals(wrapperType)) {
        return char.class;
    } else {
        Log log = LogFactory.getLog(MethodUtils.class);
        if (log.isDebugEnabled()) {
            log.debug("Not a known primitive wrapper class: " + wrapperType);
        }
        return null;
    }
}

From source file:com.thoughtworks.go.server.security.GoExceptionTranslationFilter.java

protected void sendStartAuthentication(ServletRequest request, ServletResponse response, FilterChain chain,
        AuthenticationException reason) throws ServletException, IOException {
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    HttpServletResponse httpResponse = (HttpServletResponse) response;

    //TODO: This is a hack for bug #3175, we should revisit this code in V2.0
    if (isJson(httpRequest) || isJsonFormat(httpRequest)) {
        httpResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
        return;//from  w  ww.  j  av  a  2  s  .c  o  m
    }

    final Log logger = LogFactory.getLog(GoExceptionTranslationFilter.class);
    SavedRequest savedRequest = new SavedRequest(httpRequest, getPortResolver());

    if (logger.isDebugEnabled()) {
        logger.debug("Authentication entry point being called; SavedRequest added to Session: " + savedRequest);
    }

    if (isCreateSessionAllowed() && shouldRedirect(savedRequest.getRequestUrl())) {
        // Store the HTTP request itself. Used by AbstractProcessingFilter
        // for redirection after successful authentication (SEC-29)
        httpRequest.getSession().setAttribute(AbstractProcessingFilter.SPRING_SECURITY_SAVED_REQUEST_KEY,
                savedRequest);
    }

    // SEC-112: Clear the SecurityContextHolder's Authentication, as the
    // existing Authentication is no longer considered valid
    SecurityContextHolder.getContext().setAuthentication(null);

    determineAuthenticationPoint(httpRequest).commence(httpRequest, response, reason);
}

From source file:net.sf.classifier4J.bayesian.WordProbability.java

private void calculateProbability() {
    // the logger can't be a field because this class might be serialized 
    Log log = LogFactory.getLog(this.getClass());

    String method = "calculateProbability() ";

    if (log.isDebugEnabled()) {
        log.debug(method + "START");

        log.debug(method + "matchingCount = " + matchingCount);
        log.debug(method + "nonMatchingCount = " + nonMatchingCount);
    }//from ww  w  .java  2  s . co m

    double result = IClassifier.NEUTRAL_PROBABILITY;

    if (matchingCount == 0) {
        if (nonMatchingCount == 0) {
            result = IClassifier.NEUTRAL_PROBABILITY;
        } else {
            result = IClassifier.LOWER_BOUND;
        }
    } else {
        result = BayesianClassifier
                .normaliseSignificance((double) matchingCount / (double) (matchingCount + nonMatchingCount));
    }

    probability = result;

    if (log.isDebugEnabled()) {
        log.debug(method + "END Calculated [" + probability + "]");
    }
}