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.anyframe.oden.admin.listener.JasperContextLoaderListener.java

@Override
public void contextInitialized(ServletContextEvent event) {
    Log logger = LogFactory.getLog(JasperContextLoaderListener.class);
    try {/*from  www .  j a  v a  2s.c  o  m*/
        Class.forName("org.apache.jasper.compiler.JspRuntimeContext");
    } catch (ClassNotFoundException e) {
        if (logger.isDebugEnabled()) {
            logger.debug(e.getMessage());
        }
    }
}

From source file:org.apache.axiom.om.util.CommonUtils.java

/**
 * Writes the om to a log.debug./*from  w w  w .j a  va  2  s .co  m*/
 * Also calculates the length of the message.
 * @param om OMElement
 * @param log Log
 * @param limit limit of message to write
 * @param format OMOutputFormat
 * @return length of entire message
 */
public static long logDebug(OMElement om, Log log, int limit, OMOutputFormat format) {
    LogOutputStream logStream = new LogOutputStream(log, limit);

    try {
        om.serialize(logStream, format);
        logStream.flush();
        logStream.close();
    } catch (Throwable t) {
        // Problem occur while logging. Log error and continue
        log.debug(t);
        log.error(t);
    }

    return logStream.getLength();
}

From source file:org.apache.camel.processor.PipelineHelper.java

/**
 * Should we continue processing the exchange?
 *
 * @param exchange the next exchange/*from w w w.  j ava 2s  .  com*/
 * @param message a message to use when logging that we should not continue processing
 * @param log a logger
 * @return <tt>true</tt> to continue processing, <tt>false</tt> to break out, for example if an exception occurred.
 */
public static boolean continueProcessing(Exchange exchange, String message, Log log) {
    // check for error if so we should break out
    boolean exceptionHandled = hasExceptionBeenHandledByErrorHandler(exchange);
    if (exchange.isFailed() || exchange.isRollbackOnly() || exceptionHandled) {
        // The Exchange.ERRORHANDLED_HANDLED property is only set if satisfactory handling was done
        // by the error handler. It's still an exception, the exchange still failed.
        if (log.isDebugEnabled()) {
            StringBuilder sb = new StringBuilder();
            sb.append("Message exchange has failed " + message + " for exchange: ").append(exchange);
            if (exchange.isRollbackOnly()) {
                sb.append(" Marked as rollback only.");
            }
            if (exchange.getException() != null) {
                sb.append(" Exception: ").append(exchange.getException());
            }
            if (exchange.hasOut() && exchange.getOut().isFault()) {
                sb.append(" Fault: ").append(exchange.getOut());
            }
            if (exceptionHandled) {
                sb.append(" Handled by the error handler.");
            }
            log.debug(sb.toString());
        }

        return false;
    }

    // check for stop
    Object stop = exchange.getProperty(Exchange.ROUTE_STOP);
    if (stop != null) {
        boolean doStop = exchange.getContext().getTypeConverter().convertTo(Boolean.class, exchange, stop);
        if (doStop) {
            if (log.isDebugEnabled()) {
                log.debug(
                        "ExchangeId: " + exchange.getExchangeId() + " is marked to stop routing: " + exchange);
            }
            return false;
        }
    }

    return true;
}

From source file:org.apache.cocoon.servlet.multipart.MultipartConfigurationHelper.java

/**
 * Configure this from the settings object.
 * @param settings//from  w w w.  j a va 2  s. co m
 */
public void configure(Settings settings, Log logger) {
    String value;

    value = settings.getProperty(KEY_UPLOADS_ENABLE);
    if (value != null) {
        setEnableUploads(BooleanUtils.toBoolean(value));
    }
    value = settings.getProperty(KEY_UPLOADS_DIRECTORY);
    if (value != null) {
        setUploadDirectory(value);
    }
    value = settings.getProperty(KEY_UPLOADS_AUTOSAVE);
    if (value != null) {
        setAutosaveUploads(BooleanUtils.toBoolean(value));
    }
    value = settings.getProperty(KEY_UPLOADS_OVERWRITE);
    if (value != null) {
        setOverwriteUploads(value);
    }
    value = settings.getProperty(KEY_UPLOADS_MAXSIZE);
    if (value != null) {
        setMaxUploadSize(Integer.valueOf(value).intValue());
    }

    final String uploadDirParam = getUploadDirectory();
    File uploadDir;
    if (uploadDirParam != null) {
        uploadDir = new File(uploadDirParam);
        if (logger.isDebugEnabled()) {
            logger.debug("Using upload-directory " + uploadDir);
        }
    } else {
        uploadDir = new File(settings.getWorkDirectory(), "upload-dir" + File.separator);
        if (logger.isDebugEnabled()) {
            logger.debug("Using default upload-directory " + uploadDir);
        }
    }

    uploadDir.mkdirs();
    setUploadDirectory(uploadDir.getAbsolutePath());
}

From source file:org.apache.cocoon.transformation.helpers.FormValidatorHelper.java

/**
 * Set up the complementary configuration file.  Please note that
 * multiple Actions can share the same configurations.  By using
 * this approach, we can limit the number of config files.
 * Also note that the configuration file does not have to be a file.
 *
 * This is based on the similar named functions in
 * org.apache.cocoon.acting.AbstractComplimentaryConfigurableAction
 * with the addition of reloadable configuration files, reloadable
 * flagg, manager, and logger  parameter.
 *
 * @param descriptor URL of descriptor.xml file @see org.apache.cocoon.acting.AbstractComplimentaryConfigurableAction
 * @param resolver//from   ww w .ja  v  a 2s.  com
 * @param reloadable set to <code>true</code> if changes of
 * <code>descriptor</code> should trigger a reload. Note that this
 * only works if <code>Source</code> is able to determine the
 * modification time @see org.apache.cocoon.environment.Source
 * @param logger used to send debug and error messages to
 * @return up-to-date configuration, either (re)loaded or cached.
 */

protected static Configuration getConfiguration(String descriptor, SourceResolver resolver, boolean reloadable,
        Log logger) throws ConfigurationException {

    if (descriptor == null) {
        throw new ConfigurationException("The form descriptor is not set!");
    }

    ConfigurationHelper conf = null;
    synchronized (FormValidatorHelper.configurations) {
        Source source = null;
        try {
            source = resolver.resolveURI(descriptor);
            conf = (ConfigurationHelper) FormValidatorHelper.configurations.get(source.getURI());
            if (conf == null || (reloadable && conf.lastModified != source.getLastModified())) {
                logger.debug("(Re)Loading " + descriptor);

                if (conf == null) {
                    conf = new ConfigurationHelper();
                }

                SAXConfigurationHandler builder = new SAXConfigurationHandler();
                SourceUtil.toSAX(source, builder);

                conf.lastModified = source.getLastModified();
                conf.configuration = builder.getConfiguration();

                FormValidatorHelper.cacheConfiguration(source.getURI(), conf);
            } else {
                logger.debug("Using cached configuration for " + descriptor);
            }
        } catch (Exception e) {
            logger.error("Could not configure Database mapping environment", e);
            throw new ConfigurationException(
                    "Error trying to load configurations for resource: " + source.getURI());
        } finally {
            resolver.release(source);
        }
    }

    return conf.configuration;
}

From source file:org.apache.cocoon.transformation.helpers.FormValidatorHelper.java

/**
 * Iterate over a set of configurations and return the one whose
 * name matches the given one./*from   w  ww  . j  a  va 2 s  . c  o  m*/
 *
 * @param conf set of configurations
 * @param name name of configuration
 * @param logger
 * @return specified configuration or <code>null</code> if not found.
 */
protected static Configuration getConfigurationByName(Configuration[] conf, String name, Log logger) {
    int j = 0;
    boolean found = false;
    String setname = null;
    for (j = 0; j < conf.length; j++) {
        setname = conf[j].getAttribute("name", "");
        if (name.trim().equals(setname.trim())) {
            found = true;
            break;
        }
    }
    if (!found) {
        logger.debug("FormValidatorHelper.getConfigurationByName: configuration " + name + " not found.");
        return null;
    }
    return conf[j];
}

From source file:org.apache.cocoon.transformation.helpers.FormValidatorHelper.java

/**
 * Get an attribute for a parameter as specified in
 * descriptor.xml.//from  www.j  av  a2 s .co m
 *
 * @param descriptor URL of descriptor.xml file @see org.apache.cocoon.acting.AbstractComplimentaryConfigurableAction
 * @param resolver
 * @param reloadable set to <code>true</code> if changes of
 * <code>descriptor</code> should trigger a reload. Note that this
 * only works if <code>Source</code> is able to determine the
 * modification time @see org.apache.cocoon.environment.Source
 * @param logger used to send debug and error messages to
 * @param attribute attribute name
 * @return attribute value or <code>null</code>
 */
public static String getParameterAttributes(String descriptor, SourceResolver resolver, boolean reloadable,
        String constraintset, String parameter, String attribute, Log logger) {
    try {
        Configuration conf = getConfiguration(descriptor, resolver, reloadable, logger);
        Configuration[] desc = conf.getChildren("parameter");
        Configuration[] csets = conf.getChildren("constraint-set");

        Configuration cset = getConfigurationByName(csets, constraintset, logger);

        Configuration[] set = cset.getChildren("validate");
        Configuration constraints = getConfigurationByName(set, parameter, logger);
        Configuration descr = getConfigurationByName(desc, parameter, logger);
        return constraints.getAttribute(attribute, descr.getAttribute(attribute, ""));
    } catch (Exception e) {
        logger.debug("FormValidatorHelper.getParameterAttributes Exception " + e);
    }

    return "";
}

From source file:org.apache.cocoon.transformation.helpers.PreemptiveLoader.java

/**
 * Start the preemptive loading/*from  w  w  w  . j ava2 s  .c o m*/
 * @param resolver  A source resolver
 * @param logger    A logger
 */
public void process(SourceResolver resolver, Log logger) {
    this.alive = true;
    if (logger.isDebugEnabled()) {
        logger.debug("PreemptiveLoader: Starting preemptive loading");
    }

    while (this.alive) {
        while (this.loadList.size() > 0) {
            Object[] object = (Object[]) this.loadList.get(0);
            final String uri = (String) object[1];
            this.loadList.remove(0);
            synchronized (object[3]) {
                ((List) object[3]).remove(uri);
            }

            Source source = null;
            XMLByteStreamCompiler serializer;

            try {
                if (logger.isDebugEnabled()) {
                    logger.debug("PreemptiveLoader: Loading " + uri);
                }

                source = resolver.resolveURI(uri);
                serializer = new XMLByteStreamCompiler();

                SourceUtil.toSAX(source, serializer);

                SourceValidity[] validities = new SourceValidity[1];
                validities[0] = new ExpiresValidity(((Long) object[2]).longValue() * 1000); // milliseconds!
                CachedResponse response = new CachedResponse(validities, (byte[]) serializer.getSAXFragment());
                ((IncludeCacheStorageProxy) object[0]).put(uri, response);

            } catch (Exception ignore) {
                // all exceptions are ignored!
            } finally {
                resolver.release(source);
            }
            if (logger.isDebugEnabled()) {
                logger.debug("PreemptiveLoader: Finished loading " + uri);
            }
        }
        synchronized (this.cacheStorageProxyMap) {
            try {
                this.cacheStorageProxyMap.wait();
            } catch (InterruptedException e) {
            }
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug("PreemptiveLoader: Finished preemptive loading");
    }
}

From source file:org.apache.fop.logging.LoggingElementListObserver.java

/** @see org.apache.fop.layoutmgr.ElementListObserver.Observer */
public void observe(List elementList, String category, String id) {
    Log log = LogFactory.getLog(LoggingElementListObserver.class.getName() + "." + category);
    if (!log.isDebugEnabled()) {
        return;//from  w  ww  .  jav a2s. c  o m
    }
    log.debug(" ");
    int len = (elementList != null ? ElementListUtils.calcContentLength(elementList) : 0);
    log.debug("ElementList: category=" + category + ", id=" + id + ", len=" + len + "mpt");
    if (elementList == null) {
        log.debug("<<empty list>>");
        return;
    }
    ListIterator tempIter = elementList.listIterator();
    ListElement temp;
    while (tempIter.hasNext()) {
        temp = (ListElement) tempIter.next();
        if (temp.isBox()) {
            log.debug(tempIter.previousIndex() + ") " + temp);
        } else if (temp.isGlue()) {
            log.debug(tempIter.previousIndex() + ") " + temp);
        } else {
            log.debug(tempIter.previousIndex() + ") " + temp);
        }
        if (temp.getPosition() != null) {
            log.debug("            " + temp.getPosition());
        }
    }
    log.debug(" ");
}

From source file:org.apache.fop.visual.ConvertUtils.java

/**
 * Calls an external converter application (GhostScript, for example).
 * @param cmd the full command//from  w w  w .j  a v a2 s . c o  m
 * @param envp array of strings, each element of which has environment variable settings
 * in format name=value.
 * @param workDir the working directory of the subprocess, or null if the subprocess should
 * inherit the working directory of the current process.
 * @param log the logger to log output by the external application to
 * @throws IOException in case the external call fails
 */
public static void convert(String cmd, String[] envp, File workDir, final Log log) throws IOException {
    log.debug(cmd);

    Process process = null;
    try {
        process = Runtime.getRuntime().exec(cmd, envp, null);

        //Redirect stderr output
        RedirectorLineHandler errorHandler = new AbstractRedirectorLineHandler() {
            public void handleLine(String line) {
                log.error("ERR> " + line);
            }
        };
        StreamRedirector errorRedirector = new StreamRedirector(process.getErrorStream(), errorHandler);

        //Redirect stdout output
        RedirectorLineHandler outputHandler = new AbstractRedirectorLineHandler() {
            public void handleLine(String line) {
                log.debug("OUT> " + line);
            }
        };
        StreamRedirector outputRedirector = new StreamRedirector(process.getInputStream(), outputHandler);
        new Thread(errorRedirector).start();
        new Thread(outputRedirector).start();

        process.waitFor();
    } catch (java.lang.InterruptedException ie) {
        throw new IOException("The call to the external converter failed: " + ie.getMessage());
    } catch (java.io.IOException ioe) {
        throw new IOException("The call to the external converter failed: " + ioe.getMessage());
    }

    int exitValue = process.exitValue();
    if (exitValue != 0) {
        throw new IOException("The call to the external converter failed. Result: " + exitValue);
    }

}