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.apache.jcs.engine.memory.mru.LRUvsMRUPerformanceTest.java

/**
 * A unit test for JUnit//from   w  w w  .j  a v a  2 s . c om
 *
 * @exception Exception
 *                Description of the Exception
 */
public void testSimpleLoad() throws Exception {
    Log log1 = LogFactory.getLog(LRUMemoryCache.class);
    if (log1.isDebugEnabled()) {
        System.out.println("The log level must be at info or above for the a performance test.");
        return;
    }
    Log log2 = LogFactory.getLog(MRUMemoryCache.class);
    if (log2.isDebugEnabled()) {
        System.out.println("The log level must be at info or above for the a performance test.");
        return;
    }
    doWork();

    assertTrue("Ratio is unacceptible.", this.ratioPut < target);
    assertTrue("Ratio is unacceptible.", this.ratioGet < target);
}

From source file:org.apache.jcs.JCSvsHashtablePerformanceTest.java

/**
 * A unit test for JUnit/* ww  w .  jav a  2  s  .  co m*/
 *
 * @exception Exception
 *                Description of the Exception
 */
public void testSimpleLoad() throws Exception {
    Log log1 = LogFactory.getLog(LRUMemoryCache.class);
    if (log1.isDebugEnabled()) {
        System.out.println("The log level must be at info or above for the a performance test.");
        return;
    }
    Log log2 = LogFactory.getLog(JCS.class);
    if (log2.isDebugEnabled()) {
        System.out.println("The log level must be at info or above for the a performance test.");
        return;
    }
    doWork();
    assertTrue(this.ratioPut < target);
    assertTrue(this.ratioGet < target);
}

From source file:org.apache.jcs.utils.struct.JCSvsCommonsLRUMapPerformanceTest.java

/**
 * A unit test for JUnit//from  w  ww  . j ava2  s  . c  om
 *
 * @exception Exception
 *                Description of the Exception
 */
public void testSimpleLoad() throws Exception {
    Log log = LogFactory.getLog(LRUMap.class);
    if (log.isDebugEnabled()) {
        System.out.println("The log level must be at info or above for the a performance test.");
        return;
    }

    doWork();
    assertTrue(this.ratioPut < target);
    assertTrue(this.ratioGet < target);
}

From source file:org.apache.jsieve.Command.java

/**
 * @see org.apache.jsieve.Executable#execute(MailAdapter, SieveContext)
 *///from w w w  . java2 s. c  o  m
public Object execute(MailAdapter mail, SieveContext context) throws SieveException {
    Log log = context.getLog();
    if (log.isDebugEnabled()) {
        log.debug(toString());
        coordinate.debugDiagnostics(log);
    }
    // commands are executed after the parsing phase
    // recursively from the top level block
    // so need to use the coordinate recorded from the parse
    context.setCoordinate(coordinate);
    final ExecutableCommand executable = context.getCommandManager().getCommand(getName());
    final Object result = executable.execute(mail, getArguments(), getBlock(), context);
    return result;
}

From source file:org.apache.jsieve.mailet.FileIntoAction.java

/**
 * <p>//from   w ww. j  ava  2  s .c  om
 * Executes the passed ActionFileInto.
 * </p>
 * 
 * <p>
 * This implementation accepts any destination with the root of <code>INBOX</code>.
 * </p>
 * 
 * <p>
 * As the current POP3 server does not support sub-folders, the mail is
 * stored in the INBOX for the recipient of the mail and the full intended
 * destination added as a prefix to the message's subject.
 * </p>
 * 
 * <p>
 * When IMAP support is added to James, it will be possible to support
 * sub-folders of <code>INBOX</code> fully.
 * </p>
 * 
 * @param anAction
 * @param aMail
 * @param context not null
 * @throws MessagingException
 */
@SuppressWarnings("deprecation")
public void execute(ActionFileInto anAction, Mail aMail, final ActionContext context)
        throws MessagingException {
    String destinationMailbox = anAction.getDestination();
    MailAddress recipient;
    boolean delivered = false;
    try {
        recipient = ActionUtils.getSoleRecipient(aMail);
        MimeMessage localMessage = createMimeMessage(aMail, recipient);

        if (!(destinationMailbox.length() > 0 && destinationMailbox.charAt(0) == HIERARCHY_DELIMITER)) {
            destinationMailbox = HIERARCHY_DELIMITER + destinationMailbox;
        }

        final String mailbox = destinationMailbox.replace(HIERARCHY_DELIMITER, '/');
        final String host;
        if (mailbox.charAt(0) == '/') {
            host = "@localhost";
        } else {
            host = "@localhost/";
        }
        final String url = "mailbox://" + recipient.getUser() + host + mailbox;
        //TODO: copying this message so many times seems a waste
        context.post(url, localMessage);
        delivered = true;
    } catch (MessagingException ex) {
        final Log log = context.getLog();
        if (log.isDebugEnabled()) {
            log.debug("Error while storing mail into. " + destinationMailbox, ex);
        }
        throw ex;
    } finally {
        // Ensure the mail is always ghosted
        aMail.setState(Mail.GHOST);
    }
    if (delivered) {
        final Log log = context.getLog();
        if (log.isDebugEnabled()) {
            log.debug("Filed Message ID: " + aMail.getMessage().getMessageID() + " into destination: \""
                    + destinationMailbox + "\"");
        }
    }
}

From source file:org.apache.jsieve.mailet.RedirectAction.java

/**
 * Method execute executes the passed ActionRedirect.
 * //from  ww  w . j a  v  a 2  s. co m
 * @param anAction not nul
 * @param aMail not null
 * @param context not null
 * @throws MessagingException
 */
public void execute(ActionRedirect anAction, Mail aMail, ActionContext context) throws MessagingException {
    ActionUtils.detectAndHandleLocalLooping(aMail, context, "redirect");
    Collection<MailAddress> recipients = new ArrayList<MailAddress>(1);
    recipients.add(new MailAddress(new InternetAddress(anAction.getAddress())));
    MailAddress sender = aMail.getSender();
    context.post(sender, recipients, aMail.getMessage());
    aMail.setState(Mail.GHOST);
    Log log = context.getLog();
    if (log.isDebugEnabled()) {
        log.debug("Redirected Message ID: " + aMail.getMessage().getMessageID() + " to \""
                + anAction.getAddress() + "\"");
    }
}

From source file:org.apache.jsieve.ScriptCoordinate.java

/**
 * Logs diagnotic information about the script coordinate.
 * //w ww.  j a v  a 2 s.com
 * @param logger
 *            <code>Log</code>, not null
 */
public void debugDiagnostics(Log logger) {
    if (logger.isDebugEnabled()) {
        logger.debug("Expression starts line " + startLineNumber + " column " + startColumnNumber);
        logger.debug("Expression ends line " + endLineNumber + " column " + endColumnNumber);
    }
}

From source file:org.apache.jsieve.Test.java

/**
 * Is this test passed for the given mail?
 * @param mail not null// w ww . j  a  v a  2 s  . com
 * @param context not null
 * @return true when the test passes, false otherwise
 * @throws LookupException
 * @throws SieveException
 */
public boolean isTestPassed(MailAdapter mail, SieveContext context) throws LookupException, SieveException {
    Log log = context.getLog();
    if (log.isDebugEnabled()) {
        log.debug(toString());
    }
    final String name = getName();
    final ExecutableTest test = context.getTestManager().getTest(name);
    return test.execute(mail, getArguments(), context);
}

From source file:org.apache.jxtadoop.io.IOUtils.java

/**
 * Close the Closeable objects and <b>ignore</b> any {@link IOException} or 
 * null pointers. Must only be used for cleanup in exception handlers.
 * @param log the log to record problems to at debug level. Can be null.
 * @param closeables the objects to close
 *//*from   www.j a v  a 2 s .  co  m*/
public static void cleanup(Log log, java.io.Closeable... closeables) {
    for (java.io.Closeable c : closeables) {
        if (c != null) {
            try {
                c.close();
            } catch (IOException e) {
                LOG.debug("Exception in closing the stream : " + e.getMessage());
                if (log != null && log.isDebugEnabled()) {
                    log.debug("Exception in closing " + c, e);
                }
            }
        }
    }
}

From source file:org.apache.nutch.util.ThreadPool.java

/**
 * Creates a pool of numThreads size./*  w w w. ja v  a2 s .  c o  m*/
 * These threads sit around waiting for jobs to
 * be posted to the list.
 */
public ThreadPool(int numThreads) {
    this.numThreads = numThreads;
    jobs = new Vector(37);
    running = true;

    for (int i = 0; i < numThreads; i++) {
        TaskThread t = new TaskThread();
        t.start();
    }
    Log l = LogFactory.getLog("org.apache.nutch.util");
    if (l.isDebugEnabled()) {
        l.debug("ThreadPool created with " + numThreads + " threads.");
    }
}