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

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

Introduction

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

Prototype

void info(Object message);

Source Link

Document

Logs a message with info log level.

Usage

From source file:org.apache.tez.runtime.library.shuffle.common.ShuffleUtils.java

public static void shuffleToDisk(DiskFetchedInput fetchedInput, InputStream input, long compressedLength,
        Log LOG) throws IOException {
    // Copy data to local-disk
    OutputStream output = fetchedInput.getOutputStream();
    long bytesLeft = compressedLength;
    try {/*from  w  w w .  j  a  v  a2s  .c  om*/
        final int BYTES_TO_READ = 64 * 1024;
        byte[] buf = new byte[BYTES_TO_READ];
        while (bytesLeft > 0) {
            int n = input.read(buf, 0, (int) Math.min(bytesLeft, BYTES_TO_READ));
            if (n < 0) {
                throw new IOException(
                        "read past end of stream reading " + fetchedInput.getInputAttemptIdentifier());
            }
            output.write(buf, 0, n);
            bytesLeft -= n;
            // metrics.inputBytes(n);
        }

        LOG.info("Read " + (compressedLength - bytesLeft) + " bytes from input for "
                + fetchedInput.getInputAttemptIdentifier());

        output.close();
    } catch (IOException ioe) {
        // Close the streams
        IOUtils.cleanup(LOG, input, output);

        // Re-throw
        throw ioe;
    }

    // Sanity check
    if (bytesLeft != 0) {
        throw new IOException("Incomplete input received for " + fetchedInput.getInputAttemptIdentifier() + " ("
                + bytesLeft + " bytes missing of " + compressedLength + ")");
    }
}

From source file:org.apache.tika.server.TikaResource.java

public static void logRequest(Log logger, UriInfo info, Metadata metadata) {
    if (metadata.get(org.apache.tika.metadata.HttpHeaders.CONTENT_TYPE) == null) {
        logger.info(String.format("%s (autodetecting type)", info.getPath()));
    } else {/*from  w ww  .ja v a  2  s.c o m*/
        logger.info(String.format("%s (%s)", info.getPath(),
                metadata.get(org.apache.tika.metadata.HttpHeaders.CONTENT_TYPE)));
    }
}

From source file:org.apache.tiles.access.TilesAccess.java

/**
 * Configures the container to be used in the application.
 *
 * @param context The Tiles application context object to use.
 * @param container The container object to set.
 * @param key The key under which the container will be stored.
 * @throws TilesAccessException If something goes wrong during manipulation of the
 * context.//ww w .  j av  a 2  s  .  c o m
 * @since 2.1.2
 */
public static void setContainer(TilesApplicationContext context, TilesContainer container, String key) {
    Log log = LogFactory.getLog(TilesAccess.class);
    if (key == null) {
        key = CONTAINER_ATTRIBUTE;
    }

    if (container == null) {
        if (log.isInfoEnabled()) {
            log.info("Removing TilesContext for context: " + context.getClass().getName());
        }
        context.getApplicationScope().remove(key);
    }
    if (container != null && log.isInfoEnabled()) {
        log.info("Publishing TilesContext for context: " + context.getClass().getName());
    }
    context.getApplicationScope().put(key, container);
}

From source file:org.apache.tiles.access.TilesAccess.java

/**
 * Configures the default container to be used in the application.
 *
 * @param context The (application) context object to use.
 * @param container The container object to set.
 * @throws TilesAccessException If something goes wrong during manipulation of the
 * context./*from   w  ww . j a v a 2 s . c  o  m*/
 * @deprecated Use {@link #setContainer(TilesApplicationContext, TilesContainer)}.
 */
@Deprecated
public static void setContainer(Object context, TilesContainer container) {
    Log log = LogFactory.getLog(TilesAccess.class);
    if (container == null) {
        if (log.isInfoEnabled()) {
            log.info("Removing TilesContext for context: " + context.getClass().getName());
        }
        removeAttribute(context, CONTAINER_ATTRIBUTE);
    }
    if (container != null && log.isInfoEnabled()) {
        log.info("Publishing TilesContext for context: " + context.getClass().getName());
    }
    setAttribute(context, CONTAINER_ATTRIBUTE, container);
}

From source file:org.apache.tiles.context.AbstractTilesApplicationContextFactory.java

/**
 * Creates the Tiles application context factory.
 *
 * @param preliminaryContext The preliminary {@link TilesApplicationContext}
 * that allows access to the initialization parameters.
 * @return The factory./*from ww  w  .j  a v  a  2s .  co  m*/
 * @since 2.1.1
 */
public static AbstractTilesApplicationContextFactory createFactory(TilesApplicationContext preliminaryContext) {
    Log log = LogFactory.getLog(AbstractTilesApplicationContextFactory.class);
    AbstractTilesApplicationContextFactory retValue;

    if (log.isInfoEnabled()) {
        log.info("Initializing Tiles2 application context. . .");
    }

    Map<String, String> params = preliminaryContext.getInitParams();

    String className = params.get(APPLICATION_CONTEXT_FACTORY_INIT_PARAM);

    if (className != null) {
        retValue = (AbstractTilesApplicationContextFactory) ClassUtil.instantiate(className);
    } else {
        retValue = new ChainedTilesApplicationContextFactory();
    }

    if (retValue instanceof Initializable) {
        ((Initializable) retValue).init(params);
    }

    if (log.isInfoEnabled()) {
        log.info("Finished initializing Tiles2 application context.");
    }

    return retValue;
}

From source file:org.apache.tiles.jsp.context.JspUtil.java

/**
 * Configures the container to be used in the application.
 *
 * @param context The page context object to use.
 * @param container The container object to set.
 * @param key The key under which the container will be stored.
 * @since 2.1.2//  w ww .j  a v  a 2  s.c  o  m
 */
public static void setContainer(PageContext context, TilesContainer container, String key) {
    Log log = LogFactory.getLog(ServletUtil.class);
    if (key == null) {
        key = TilesAccess.CONTAINER_ATTRIBUTE;
    }

    if (container == null) {
        if (log.isInfoEnabled()) {
            log.info("Removing TilesContext for context: " + context.getClass().getName());
        }
        context.removeAttribute(key, PageContext.APPLICATION_SCOPE);
    }
    if (container != null && log.isInfoEnabled()) {
        log.info("Publishing TilesContext for context: " + context.getClass().getName());
    }
    context.setAttribute(key, container, PageContext.APPLICATION_SCOPE);
}

From source file:org.apache.tiles.servlet.context.ServletUtil.java

/**
 * Configures the container to be used in the application.
 *
 * @param context The servlet context object to use.
 * @param container The container object to set.
 * @param key The key under which the container will be stored.
 * @since 2.1.2/*from   w  ww. j a  v a  2s  . c  o  m*/
 */
public static void setContainer(ServletContext context, TilesContainer container, String key) {
    Log log = LogFactory.getLog(ServletUtil.class);
    if (key == null) {
        key = TilesAccess.CONTAINER_ATTRIBUTE;
    }

    if (container == null) {
        if (log.isInfoEnabled()) {
            log.info("Removing TilesContext for context: " + context.getClass().getName());
        }
        context.removeAttribute(key);
    }
    if (container != null && log.isInfoEnabled()) {
        log.info("Publishing TilesContext for context: " + context.getClass().getName());
    }
    context.setAttribute(key, container);
}

From source file:org.apache.tomcat.util.log.CommonLogHandler.java

/**
 * Prints log message and stack trace.//from   w  w w  . j a  v  a2s .co  m
 * This method should be overriden by real logger implementations
 *
 * @param   prefix      optional prefix. 
 * @param   message      the message to log. 
 * @param   t      the exception that was thrown.
 * @param   verbosityLevel   what type of message is this?
 *             (WARNING/DEBUG/INFO etc)
 */
public void log(String prefix, String msg, Throwable t, int verbosityLevel) {
    if (prefix == null)
        prefix = "tomcat";

    org.apache.commons.logging.Log l = (org.apache.commons.logging.Log) loggers.get(prefix);
    if (l == null) {
        l = LogFactory.getLog(prefix);
        loggers.put(prefix, l);
    }

    if (verbosityLevel > this.level)
        return;

    if (t == null) {
        if (verbosityLevel == Log.FATAL)
            l.fatal(msg);
        else if (verbosityLevel == Log.ERROR)
            l.error(msg);
        else if (verbosityLevel == Log.WARNING)
            l.warn(msg);
        else if (verbosityLevel == Log.INFORMATION)
            l.info(msg);
        else if (verbosityLevel == Log.DEBUG)
            l.debug(msg);
    } else {
        if (verbosityLevel == Log.FATAL)
            l.fatal(msg, t);
        else if (verbosityLevel == Log.ERROR)
            l.error(msg, t);
        else if (verbosityLevel == Log.WARNING)
            l.warn(msg, t);
        else if (verbosityLevel == Log.INFORMATION)
            l.info(msg, t);
        else if (verbosityLevel == Log.DEBUG)
            l.debug(msg, t);
    }
}

From source file:org.apache.tools.ant.listener.CommonsLoggingListener.java

private void realLog(final Log log, final String message, final int priority, final Throwable t) {
    final PrintStream tmpOut = System.out;
    final PrintStream tmpErr = System.err;
    System.setOut(out);/*from  ww w  . j a  va  2s .c  o  m*/
    System.setErr(err);
    switch (priority) {
    case Project.MSG_ERR:
        if (t == null) {
            log.error(message);
        } else {
            log.error(message, t);
        }
        break;
    case Project.MSG_WARN:
        if (t == null) {
            log.warn(message);
        } else {
            log.warn(message, t);
        }
        break;
    case Project.MSG_INFO:
        if (t == null) {
            log.info(message);
        } else {
            log.info(message, t);
        }
        break;
    case Project.MSG_VERBOSE:
        log.debug(message);
        break;
    case Project.MSG_DEBUG:
        log.debug(message);
        break;
    default:
        log.error(message);
        break;
    }
    System.setOut(tmpOut);
    System.setErr(tmpErr);
}

From source file:org.asimba.utility.storage.jgroups.RetrieveRepeater.java

public void logReport(Log logger) {
    logger.info("");
    logger.info(RetrieveRepeater.class.toString());
    logger.info("Invocations: " + invocations);
    logger.info("Successes per cycle (0 means direct succes):");
    for (int i = 0; i < repetitions.length; ++i) {
        logger.info("  " + i + " after " + (i * sleep) + " msecs: " + repetitions[i]);
    }//from   www  .  j  a  v  a2  s .com
    logger.info("Failures: " + failures);
    logger.info("");
}