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

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

Introduction

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

Prototype

boolean isDebugEnabled();

Source Link

Document

Is debug logging currently enabled?

Usage

From source file:org.xchain.framework.util.IoUtil.java

/**
 * Exists to provide an upgrade path from Commons Logging to SLF4J
 * //from   w w  w  .  j a  va 2  s .  c om
 * @param out
 * @param log
 */
@Deprecated
public static void close(OutputStream out, org.apache.commons.logging.Log log) {
    if (out != null) {
        try {
            out.close();
        } catch (IOException ioe) {
            if (log != null && log.isDebugEnabled()) {
                log.debug("An exception was thrown while closing an output stream.", ioe);
            }
        }
    }
}

From source file:org.xchain.framework.util.IoUtil.java

/**
 * Exists to provide an upgrade path from Commons Logging to SLF4J
 * /*from   ww  w .ja  v a 2 s  .c o  m*/
 * @param socket
 * @param log
 */
@Deprecated
public static void close(Socket socket, org.apache.commons.logging.Log log) {
    if (socket != null) {
        try {
            socket.close();
        } catch (IOException ioe) {
            if (log != null && log.isDebugEnabled()) {
                log.debug("An exception was thrown while closing a socket.", ioe);
            }
        }
    }
}

From source file:org.xchain.framework.util.IoUtil.java

/**
 * Exists to provide an upgrade path from Commons Logging to SLF4J
 * /* w  ww  .j a v  a 2 s.  co  m*/
 * @param reader
 * @param log
 */
@Deprecated
public static void close(Reader reader, org.apache.commons.logging.Log log) {
    if (reader != null) {
        try {
            reader.close();
        } catch (IOException ioe) {
            if (log != null && log.isDebugEnabled()) {
                log.debug("An exception was thrown while closing a reader.", ioe);
            }
        }
    }
}

From source file:org.xchain.framework.util.IoUtil.java

/**
 * Exists to provide an upgrade path from Commons Logging to SLF4J
 * /*from www.  ja  v a2s .c  o m*/
 * @param writer
 * @param log
 */
@Deprecated
public static void close(Writer writer, org.apache.commons.logging.Log log) {
    if (writer != null) {
        try {
            writer.close();
        } catch (IOException ioe) {
            if (log != null && log.isDebugEnabled()) {
                log.debug("An exception was thrown while closing a writer.", ioe);
            }
        }
    }
}

From source file:rocket.logging.server.CommonsLoggingService.java

@Override
protected Logger createLoggerAdapter(final String loggerName) {
    final Log log = LogFactory.getLog(loggerName);
    return new Logger() {
        public void debug(final String message) {
            log.debug(message);//  w w w  .  j  av  a 2s  .c  o  m
        }

        public void debug(final String message, final Throwable throwable) {
            log.debug(message, throwable);
        }

        public void info(final String message) {
            log.info(message);
        }

        public void info(final String message, final Throwable throwable) {
            log.info(message, throwable);
        }

        public void warn(final String message) {
            log.warn(message);
        }

        public void warn(final String message, final Throwable throwable) {
            log.warn(message, throwable);
        }

        public void error(final String message) {
            log.error(message);
        }

        public void error(final String message, final Throwable throwable) {
            log.error(message, throwable);
        }

        public void fatal(final String message) {
            log.fatal(message);
        }

        public void fatal(final String message, final Throwable throwable) {
            log.fatal(message, throwable);
        }

        public boolean isDebugEnabled() {
            return log.isDebugEnabled();
        }

        public boolean isInfoEnabled() {
            return log.isInfoEnabled();
        }

        public boolean isWarnEnabled() {
            return log.isWarnEnabled();
        }

        public boolean isErrorEnabled() {
            return log.isErrorEnabled();
        }

        public boolean isFatalEnabled() {
            return log.isFatalEnabled();
        }
    };
}

From source file:wicket.util.thread.Task.java

/**
 * Runs this task at the given frequency. You may only call this method if
 * the task has not yet been started. If the task is already running, an
 * IllegalStateException will be thrown.
 * //www . ja  v  a 2s  .  c om
 * @param frequency
 *            The frequency at which to run the code
 * @param code
 *            The code to run
 * @throws IllegalStateException
 *             Thrown if task is already running
 */
public synchronized final void run(final Duration frequency, final ICode code) {
    if (!isStarted) {
        final Runnable runnable = new Runnable() {
            public void run() {
                // Sleep until start time
                startTime.fromNow().sleep();
                final Log log = getLog();

                while (!stop) {
                    // Get the start of the current period
                    final Time startOfPeriod = Time.now();

                    if (log.isDebugEnabled()) {
                        log.debug("Run the job: " + code.toString());
                    }

                    try {
                        // Run the user's code
                        code.run(getLog());
                    } catch (Exception e) {
                        log.error("Unhandled exception thrown by user code in task " + name, e);
                    }

                    if (log.isDebugEnabled()) {
                        log.debug("Finished with job: " + code.toString());
                    }

                    // Sleep until the period is over (or not at all if it's
                    // already passed)
                    startOfPeriod.add(frequency).fromNow().sleep();
                }
            }
        };

        // Start the thread
        final Thread thread = new Thread(runnable, name + " Task");
        thread.setDaemon(isDaemon);
        thread.start();

        // We're started all right!
        isStarted = true;
    } else {
        throw new IllegalStateException("Attempt to start task that has already been started");
    }
}

From source file:xdoclet.modules.ojb.LogHelper.java

/**
 * Logs the given debug message to stdout (if verbose is on) and to the log for the given class
 * (if the log level has been set to debug or higher).
 * /*from  ww w  .j  av  a2 s . c o m*/
 * @param alsoStdout Whether to also put the message to stdout
 * @param clazz      The clazz
 * @param posInfo    The position info, e.g. method name
 * @param msg        The message
 */
public static void debug(boolean alsoStdout, Class clazz, String posInfo, Object msg) {
    if (alsoStdout) {
        System.out.println(msg.toString());
    }

    String name = clazz.getName();

    if (posInfo != null) {
        name += "." + posInfo;
    }

    Log log = LogFactory.getLog(name);

    if (log.isDebugEnabled()) {
        log.debug(msg);
    }
}

From source file:xdoclet.modules.ojb.OjbSubTask.java

public void startProcess() throws XDocletException {
    Log log = LogUtil.getLog(OjbSubTask.class, "startProcess");

    if (log.isDebugEnabled()) {
        log.debug("destDir.toString()=" + getDestDir());
        log.debug("getTemplateURL()=" + getTemplateURL());
        log.debug("getDestinationfile()=" + getDestinationFile());
        log.debug("getOfType()=" + getOfType());
        log.debug("getExtent()=" + getExtent());
        log.debug("getHavingClassTag()=" + getHavingClassTag());
    }/*ww w.j ava  2  s.c o m*/

    startProcessForAll();
}

From source file:xdoclet.modules.ojb.TorqueSubTask.java

public void startProcess() throws XDocletException {
    Log log = LogUtil.getLog(TorqueSubTask.class, "startProcess");

    if (log.isDebugEnabled()) {
        log.debug("destDir.toString()=" + getDestDir());
        log.debug("getTemplateURL()=" + getTemplateURL());
        log.debug("getDestinationfile()=" + getDestinationFile());
        log.debug("getOfType()=" + getOfType());
        log.debug("getExtent()=" + getExtent());
        log.debug("getHavingClassTag()=" + getHavingClassTag());
    }/*from   w  w  w.  j  a v  a2 s.  com*/

    startProcessForAll();
}