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

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

Introduction

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

Prototype

boolean isInfoEnabled();

Source Link

Document

Is info logging currently enabled?

Usage

From source file:org.qedeq.base.trace.Trace.java

/**
 * Parameter information./*from w w  w.  ja  va  2s.  co  m*/
 *
 * @param   tracingClass    Class that wants to make an info entry.
 * @param   method          Method of that class.
 * @param   param           Parameter to trace.
 * @param   value           Value of parameter.
 */
public static void paramInfo(final Class tracingClass, final String method, final String param,
        final int value) {
    if (traceOn) {
        final Log log = LogFactory.getFactory().getInstance(tracingClass);
        if (log.isInfoEnabled()) {
            log.info("." + method + " " + param + "=" + value);
        }
    }
}

From source file:org.qedeq.base.trace.Trace.java

/**
 * Parameter information./*from   w  w w. j  a v  a 2  s .  co  m*/
 * @param   tracingClass    Class that wants to make an info entry.
 * @param   tracingObject   Instance that wants to make an info entry.
 * @param   method          Method of that object.
 * @param   param           Parameter to trace.
 * @param   value           Value of parameter.
 */
public static void paramInfo(final Class tracingClass, final Object tracingObject, final String method,
        final String param, final boolean value) {
    if (traceOn) {
        final Log log = LogFactory.getFactory().getInstance(tracingClass);
        if (log.isInfoEnabled()) {
            log.info("." + method + " " + param + "=" + value);
        }
    }
}

From source file:org.qedeq.base.trace.Trace.java

/**
 * Parameter information./*  w w w.j av  a2 s.c o  m*/
 *
 * @param   tracingClass    Class that wants to make an info entry.
 * @param   method          Method of that class.
 * @param   param           Parameter to trace.
 * @param   value           Value of parameter.
 */
public static void paramInfo(final Class tracingClass, final String method, final String param,
        final boolean value) {
    if (traceOn) {
        final Log log = LogFactory.getFactory().getInstance(tracingClass);
        if (log.isInfoEnabled()) {
            log.info("." + method + " " + param + "=" + value);
        }
    }
}

From source file:org.saiku.reporting.backend.component.ReportContentUtil.java

/**
 * Apply inputs (if any) to corresponding report parameters, care is taken when
 * checking parameter types to perform any necessary casting and conversion.
 *
 * @param report The report to retrieve parameter definitions and values from.         
 * @param context a ParameterContext for which the parameters will be under
 * @param validationResult the validation result that will hold the warnings. If null, a new one will be created.
 * @return the validation result containing any parameter validation errors.
 * @throws java.io.IOException if the report of this component could not be parsed.
 * @throws ResourceException   if the report of this component could not be parsed.
 *///w  w  w .  j  a  va 2 s.  c  o  m
public static ValidationResult applyInputsToReportParameters(final MasterReport report,
        final ParameterContext context, final Map<String, Object> inputs, ValidationResult validationResult)
        throws IOException, ResourceException {
    if (validationResult == null) {
        validationResult = new ValidationResult();
    }
    // apply inputs to report
    if (inputs != null) {
        final Log log = LogFactory.getLog(ReportContentUtil.class);
        final ParameterDefinitionEntry[] params = report.getParameterDefinition().getParameterDefinitions();
        final ReportParameterValues parameterValues = report.getParameterValues();
        for (final ParameterDefinitionEntry param : params) {
            final String paramName = param.getName();
            try {
                final Object computedParameter = ReportContentUtil.computeParameterValue(context, param,
                        inputs.get(paramName));
                parameterValues.put(param.getName(), computedParameter);
                if (log.isInfoEnabled()) {
                    log.info("ReportPlugin.infoParameterValues" + paramName + " "
                            + String.valueOf(inputs.get(paramName)) + " " + String.valueOf(computedParameter));
                }
            } catch (Exception e) {
                if (log.isWarnEnabled()) {
                    log.warn("ReportPlugin.logErrorParametrization" + e.getMessage()); //$NON-NLS-1$
                }
                validationResult.addError(paramName, new ValidationMessage(e.getMessage()));
            }
        }
    }
    return validationResult;
}

From source file:org.springframework.amqp.rabbit.connection.CachingConnectionFactoryTests.java

@Test
public void setAddressesEmpty() throws Exception {
    ConnectionFactory mock = mock(com.rabbitmq.client.ConnectionFactory.class);
    CachingConnectionFactory ccf = new CachingConnectionFactory(mock);
    ccf.setExecutor(mock(ExecutorService.class));
    ccf.setHost("abc");
    ccf.setAddresses("");
    ccf.createConnection();/*ww  w  . jav  a2 s . com*/
    verify(mock).isAutomaticRecoveryEnabled();
    verify(mock).setHost("abc");
    Log logger = TestUtils.getPropertyValue(ccf, "logger", Log.class);
    if (logger.isInfoEnabled()) {
        verify(mock).getHost();
        verify(mock).getPort();
    }
    verify(mock).newConnection(any(ExecutorService.class), anyString());
    verifyNoMoreInteractions(mock);
}

From source file:org.springframework.amqp.rabbit.connection.CachingConnectionFactoryTests.java

@Test
public void setUri() throws Exception {
    URI uri = new URI("amqp://localhost:1234/%2f");

    ConnectionFactory mock = mock(com.rabbitmq.client.ConnectionFactory.class);
    CachingConnectionFactory ccf = new CachingConnectionFactory(mock);
    ccf.setExecutor(mock(ExecutorService.class));

    ccf.setUri(uri);/*from  ww  w  .  j  av a2 s .  c  om*/
    ccf.createConnection();

    InOrder order = inOrder(mock);
    order.verify(mock).isAutomaticRecoveryEnabled();
    order.verify(mock).setUri(uri);
    Log logger = TestUtils.getPropertyValue(ccf, "logger", Log.class);
    if (logger.isInfoEnabled()) {
        order.verify(mock).getHost();
        order.verify(mock).getPort();
    }
    order.verify(mock).newConnection(any(ExecutorService.class), anyString());
    verifyNoMoreInteractions(mock);
}

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
 *//*  ww w .  j  a v  a2 s  . c  om*/
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.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
 *//*ww w.j  a v  a 2 s. c om*/
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.SpringApplication.java

/**
 * Called to log active profile information.
 * @param context the application context
 *///from  w w  w.j a v  a 2 s .c o m
protected void logStartupProfileInfo(ConfigurableApplicationContext context) {
    Log log = getApplicationLog();
    if (log.isInfoEnabled()) {
        String[] activeProfiles = context.getEnvironment().getActiveProfiles();
        if (ObjectUtils.isEmpty(activeProfiles)) {
            log.info("No profiles are active");
        } else {
            log.info("The following profiles are active: "
                    + StringUtils.arrayToCommaDelimitedString(activeProfiles));
        }
    }
}

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 a  v  a 2s  .  c om*/
    }
    if (log.isDebugEnabled()) {
        log.debug(getRunningMessage());
    }
}