List of usage examples for org.apache.commons.logging Log debug
void debug(Object message);
From source file:org.apache.james.transport.mailets.jsieve.delivery.SieveExecutor.java
private void sieveMessageEvaluate(MailAddress recipient, Mail aMail, ResourceLocator.UserSieveInformation userSieveInformation, Log log) throws MessagingException, IOException { try {/* w w w .j av a2 s. com*/ SieveMailAdapter aMailAdapter = new SieveMailAdapter(aMail, mailetContext, actionDispatcher, sievePoster, userSieveInformation.getScriptActivationDate(), userSieveInformation.getScriptInterpretationDate(), recipient); aMailAdapter.setLog(log); // This logging operation is potentially costly log.debug("Evaluating " + aMailAdapter.toString() + " against \"" + recipient.asPrettyString() + "\""); factory.evaluate(aMailAdapter, factory.parse(userSieveInformation.getScriptContent())); } catch (SieveException ex) { handleFailure(recipient, aMail, ex); } catch (ParseException ex) { handleFailure(recipient, aMail, ex); } catch (TokenMgrError ex) { handleFailure(recipient, aMail, new SieveException(ex)); } }
From source file:org.apache.james.transport.mailets.jsieve.RedirectAction.java
/** * Method execute executes the passed ActionRedirect. * //from w w w .j a v a 2s. c o 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()); Log log = context.getLog(); if (log.isDebugEnabled()) { log.debug("Redirected Message ID: " + aMail.getMessage().getMessageID() + " to \"" + anAction.getAddress() + "\""); } }
From source file:org.apache.jsieve.Command.java
/** * @see org.apache.jsieve.Executable#execute(MailAdapter, SieveContext) *//*from w w w .j a va2 s . co 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.RedirectAction.java
/** * Method execute executes the passed ActionRedirect. * // www .j av a2 s.c o 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 .jav a 2 s.c om * @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.ja v a 2 s. c o m * @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.jsieve.tests.AbstractTest.java
/** * Framework method validateArguments is invoked before a Sieve Test is * executed to validate its arguments. Subclass methods are expected to * override or extend this method to perform their own validation as * appropriate./*from w w w . j av a 2s . co m*/ * * @param arguments * @param context * <code>SieveContext</code> giving comntextual information, * not null * @throws SieveException */ protected void validateArguments(Arguments arguments, SieveContext context) throws SieveException { if (!arguments.getArgumentList().isEmpty()) { final Log logger = context.getLog(); if (logger.isWarnEnabled()) { logger.warn("Unexpected arguments for " + getClass().getName()); } context.getCoordinate().logDiagnosticsInfo(logger); logger.debug(arguments); final String message = context.getCoordinate().addStartLineAndColumn("Found unexpected arguments."); throw new SyntaxException(message); } }
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 w w w .ja v a2 s .com*/ 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.logging.log4j.jcl.LoggerTest.java
@Test public void testLog() { final Log logger = LogFactory.getLog("LoggerTest"); logger.debug("Test message"); verify("List", "o.a.l.l.j.LoggerTest Test message MDC{}" + Strings.LINE_SEPARATOR); logger.debug("Exception: ", new NullPointerException("Test")); verify("List", "o.a.l.l.j.LoggerTest Exception: MDC{}" + Strings.LINE_SEPARATOR); logger.info("Info Message"); verify("List", "o.a.l.l.j.LoggerTest Info Message MDC{}" + Strings.LINE_SEPARATOR); logger.info("Info Message {}"); verify("List", "o.a.l.l.j.LoggerTest Info Message {} MDC{}" + Strings.LINE_SEPARATOR); }
From source file:org.apache.myfaces.custom.navmenu.htmlnavmenu.HtmlNavigationMenuRendererUtils.java
public static void debugTree(Log log, FacesContext facesContext, List children, int level) { for (Iterator it = children.iterator(); it.hasNext();) { UIComponent child = (UIComponent) it.next(); if (child instanceof UINavigationMenuItem) { UINavigationMenuItem item = (UINavigationMenuItem) child; StringBuffer buf = new StringBuffer(); for (int i = 0; i < level * 4; i++) buf.append(' '); log.debug(buf.toString() + "--> " + item.getItemLabel() + " id:" + item.getClientId(facesContext)); debugTree(log, facesContext, child.getChildren(), level + 1); } else if (child instanceof HtmlCommandNavigationItem) { HtmlCommandNavigationItem item = (HtmlCommandNavigationItem) child; StringBuffer buf = new StringBuffer(); for (int i = 0; i < level * 4; i++) buf.append(' '); String value;//from w w w .j av a 2 s. c o m if (item.getChildren().size() > 0 && item.getChildren().get(0) instanceof UIOutput) { UIOutput uiOutput = (UIOutput) item.getChildren().get(0); value = uiOutput.getValue() != null ? uiOutput.getValue().toString() : "?"; } else { value = item.getValue() != null ? item.getValue().toString() : ""; } log.debug(buf.toString() + value + " id:" + item.getClientId(facesContext)); debugTree(log, facesContext, child.getChildren(), level + 1); } } }