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:org.sakaiproject.tool.assessment.integration.context.IntegrationContextFactory.java

public static IntegrationContextFactory getTestInstance() {
    Log log = LogFactory.getLog(IntegrationContextFactory.class);
    log.debug("IntegrationContextFactory.getTestInstance()");
    if (instance == null) {
        try {//from w  ww .  ja  v a2 s.co  m
            FactoryUtil.setUseLocator(false);
            instance = FactoryUtil.lookup();
        } catch (Exception ex) {
            log.error("Unable to read integration context: " + ex);
        }
    }
    log.debug("instance=" + instance);
    return instance;
}

From source file:org.sakaiproject.tool.assessment.qti.util.XmlUtil.java

public static String processFormattedText(Log log, String value) {
    if (StringUtils.isEmpty(value)) {
        return value;
    }//from  ww w .  j  a  v a  2s. c  o m
    StringBuilder alertMsg = new StringBuilder();
    String finalValue = "";
    Matcher matcher = M_htmlPattern.matcher(value);
    boolean hasHtmlPattern = false;
    int index = 0;
    StringBuilder textStringBuilder = new StringBuilder();
    String tmpText = "";
    if (M_goodTagsPatterns == null || M_goodCloseTagsPatterns == null) {
        M_goodTagsPatterns = new Pattern[M_goodTags.length];
        M_goodCloseTagsPatterns = new Pattern[M_goodTags.length];
        for (int i = 0; i < M_goodTags.length; i++) {
            M_goodTagsPatterns[i] = Pattern.compile(".*<\\s*" + M_goodTags[i] + "(\\s+.*>|>|/>).*",
                    Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.DOTALL);
            M_goodCloseTagsPatterns[i] = Pattern.compile("<\\s*/\\s*" + M_goodTags[i] + "(\\s.*>|>)",
                    Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.DOTALL);
        }
    }
    while (matcher.find()) {
        hasHtmlPattern = true;
        tmpText = value.substring(index, matcher.start());
        textStringBuilder.append(convertoLTGT(tmpText));
        String group = matcher.group();
        boolean isGoodTag = false;
        for (int i = 0; i < M_goodTags.length; i++) {
            if (M_goodTagsPatterns[i].matcher(group).matches()
                    || M_goodCloseTagsPatterns[i].matcher(group).matches()) {
                textStringBuilder.append(group);
                isGoodTag = true;
                break;
            }
        }
        if (!isGoodTag) {
            textStringBuilder.append(convertoLTGT(group));
        }
        index = matcher.end();
    }
    textStringBuilder.append(convertoLTGT(value.substring(index)));
    if (hasHtmlPattern) {
        finalValue = formattedText.processFormattedText(textStringBuilder.toString(), alertMsg);
    } else {
        finalValue = formattedText.processFormattedText(convertoLTGT(value), alertMsg);
    }
    if (alertMsg.length() > 0) {
        log.debug(alertMsg.toString());
    }
    return finalValue;
}

From source file:org.seasar.struts.action.impl.ActionFactoryImpl.java

public Object getActionInstance(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping,
        Log log, MessageResources internal, ActionServlet servlet) throws IOException {
    Object actionInstance = null;
    S2Container container = SingletonS2ContainerFactory.getContainer();
    try {//from  w w w  .j a  v  a 2 s .  c o m
        if (isCreateActionWithComponentName(mapping)) {
            String componentName = this.componentNameCreator.createComponentName(container, mapping);
            actionInstance = getActionWithComponentName(componentName, servlet);
        } else {
            String actionClassName = mapping.getType();
            if (log.isDebugEnabled()) {
                log.debug(" Looking for Action instance for class " + actionClassName);
            }
            Class componentKey = this.classRegister.getClass(actionClassName);
            actionInstance = container.getComponent(componentKey);
        }
    } catch (Exception e) {
        processExceptionActionCreate(S2StrutsContextUtil.getResponse(container), mapping, log, internal, e);
        return null;
    }

    if (actionInstance instanceof Action) {
        setServlet((Action) actionInstance, servlet);
    }

    return actionInstance;
}

From source file:org.soaplab.share.SoaplabException.java

/******************************************************************************
 * Format given exception 'e' depending on how serious it it. In
 * same cases add stack trace. Log the result in the given
 * 'log'. <p>// w  ww.ja  v  a  2  s  .  c  o m
 *
 * @param e an exception to be formatted and logged
 * @param log where to log it
 *
 ******************************************************************************/
public static void formatAndLog(Throwable e, org.apache.commons.logging.Log log) {
    boolean seriousError = (e instanceof java.lang.RuntimeException);
    if (seriousError || log.isDebugEnabled()) {
        StringWriter sw = new StringWriter(500);
        e.printStackTrace(new PrintWriter(sw));
        if (seriousError)
            log.error(sw.toString());
        else
            log.debug(sw.toString());
    } else {
        log.error(e.getMessage());
    }
}

From source file:org.springbyexample.util.log.LoggerAwareBeanPostProcessorTest.java

/**
 * Tests <code>CommonsLoggerAware</code>.
 *//*from  ww w  .  ja  v  a2  s  .  co m*/
@Test
public void testCommonsAwareLogger() {
    assertNotNull("Commons logger bean is null.", commonsLoggerBean);

    Log beanLogger = commonsLoggerBean.getLogger();

    assertNotNull("Commons bean's logger is null.", commonsLoggerBean);

    beanLogger.debug(
            "Logging message from Commons bean's logger that was injected by LoggerAwareBeanPostProcessorTest.");
}

From source file:org.springframework.amqp.rabbit.listener.ContainerUtils.java

/**
 * Determine whether a message should be requeued; returns true if the throwable is a
 * {@link MessageRejectedWhileStoppingException} or defaultRequeueRejected is true and
 * there is not an {@link AmqpRejectAndDontRequeueException} in the cause chain.
 * @param defaultRequeueRejected the default requeue rejected.
 * @param throwable the throwable.//from w ww.jav a2  s. com
 * @param logger the logger to use for debug.
 * @return true to requeue.
 */
public static boolean shouldRequeue(boolean defaultRequeueRejected, Throwable throwable, Log logger) {
    boolean shouldRequeue = defaultRequeueRejected
            || throwable instanceof MessageRejectedWhileStoppingException;
    Throwable t = throwable;
    while (shouldRequeue && t != null) {
        if (t instanceof AmqpRejectAndDontRequeueException) {
            shouldRequeue = false;
        }
        t = t.getCause();
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Rejecting messages (requeue=" + shouldRequeue + ")");
    }
    return shouldRequeue;
}

From source file:org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.java

/**
 * Prepare the {@link WebApplicationContext} with the given fully loaded
 * {@link ServletContext}. This method is usually called from
 * {@link ServletContextInitializer#onStartup(ServletContext)} and is similar to the
 * functionality usually provided by a {@link ContextLoaderListener}.
 * @param servletContext the operational servlet context
 *//*from w w w  .  j av  a2 s.  c o  m*/
protected void prepareEmbeddedWebApplicationContext(ServletContext servletContext) {
    Object rootContext = servletContext
            .getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
    if (rootContext != null) {
        if (rootContext == this) {
            throw new IllegalStateException(
                    "Cannot initialize context because there is already a root application context present - "
                            + "check whether you have multiple ServletContextInitializers!");
        }
        return;
    }
    Log logger = LogFactory.getLog(ContextLoader.class);
    servletContext.log("Initializing Spring embedded WebApplicationContext");
    try {
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this);
        if (logger.isDebugEnabled()) {
            logger.debug("Published root WebApplicationContext as ServletContext attribute with name ["
                    + WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE + "]");
        }
        setServletContext(servletContext);
        if (logger.isInfoEnabled()) {
            long elapsedTime = System.currentTimeMillis() - getStartupDate();
            logger.info("Root WebApplicationContext: initialization completed in " + elapsedTime + " ms");
        }
    } catch (RuntimeException ex) {
        logger.error("Context initialization failed", ex);
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
        throw ex;
    } catch (Error ex) {
        logger.error("Context initialization failed", ex);
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
        throw ex;
    }
}

From source file:org.springframework.boot.devtools.restart.classloader.RestartClassLoader.java

/**
 * Create a new {@link RestartClassLoader} instance.
 * @param parent the parent classloader/* w  ww  .  ja v a2 s. co m*/
 * @param updatedFiles any files that have been updated since the JARs referenced in
 * URLs were created.
 * @param urls the urls managed by the classloader
 * @param logger the logger used for messages
 */
public RestartClassLoader(ClassLoader parent, URL[] urls, ClassLoaderFileRepository updatedFiles, Log logger) {
    super(urls, parent);
    Assert.notNull(parent, "Parent must not be null");
    Assert.notNull(updatedFiles, "UpdatedFiles must not be null");
    Assert.notNull(logger, "Logger must not be null");
    this.updatedFiles = updatedFiles;
    this.logger = logger;
    if (logger.isDebugEnabled()) {
        logger.debug("Created RestartClassLoader " + toString());
    }
}

From source file:org.springframework.boot.legacy.context.web.NonEmbeddedWebApplicationContext.java

/**
 * Prepare the {@link WebApplicationContext} with the given fully loaded
 * {@link ServletContext}. This method is usually called from
 * {@link ServletContextInitializer#onStartup(ServletContext)} and is similar to the
 * functionality usually provided by a {@link ContextLoaderListener}.
 * @param servletContext the operational servlet context
 *///  www . ja  va 2 s. co m
protected void prepareWebApplicationContext(ServletContext servletContext) {
    Object rootContext = servletContext
            .getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
    if (rootContext != null) {
        if (rootContext == this) {
            throw new IllegalStateException(
                    "Cannot initialize context because there is already a root application context present - "
                            + "check whether you have multiple ServletContextInitializers!");
        } else {
            return;
        }
    }
    Log logger = LogFactory.getLog(ContextLoader.class);
    servletContext.log("Initializing Spring embedded WebApplicationContext");
    WebApplicationContextUtils.registerWebApplicationScopes(getBeanFactory(), getServletContext());
    WebApplicationContextUtils.registerEnvironmentBeans(getBeanFactory(), getServletContext());
    try {
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this);
        if (logger.isDebugEnabled()) {
            logger.debug("Published root WebApplicationContext as ServletContext attribute with name ["
                    + WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE + "]");
        }
        if (logger.isInfoEnabled()) {
            long elapsedTime = System.currentTimeMillis() - getStartupDate();
            logger.info("Root WebApplicationContext: initialization completed in " + elapsedTime + " ms");
        }
    } catch (RuntimeException ex) {
        logger.error("Context initialization failed", ex);
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
        throw ex;
    } catch (Error ex) {
        logger.error("Context initialization failed", ex);
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
        throw ex;
    }
}

From source file:org.springframework.boot.StartupInfoLogger.java

public void logStarting(Log log) {
    Assert.notNull(log, "Log must not be null");
    if (log.isInfoEnabled()) {
        log.info(getStartupMessage());//  w  ww  . j av  a2 s. co m
    }
    if (log.isDebugEnabled()) {
        log.debug(getRunningMessage());
    }
}