List of usage examples for org.apache.commons.logging Log isErrorEnabled
boolean isErrorEnabled();
From source file:edu.cornell.mannlib.vitro.webapp.utils.log.LogUtils.java
private static boolean isLevelEnabled(Log log, String level) { if ("fatal".equalsIgnoreCase(level)) { return log.isFatalEnabled(); } else if ("error".equalsIgnoreCase(level)) { return log.isErrorEnabled(); } else if ("warn".equalsIgnoreCase(level)) { return log.isWarnEnabled(); } else if ("info".equalsIgnoreCase(level)) { return log.isInfoEnabled(); } else if ("debug".equalsIgnoreCase(level)) { return log.isDebugEnabled(); } else {/*from w w w . j a v a 2 s. c o m*/ return log.isTraceEnabled(); } }
From source file:com.stimulus.archiva.exception.ChainedException.java
public static Level getLoggingLevel(Log logger) { if (logger.isDebugEnabled()) return Level.DEBUG; else if (logger.isInfoEnabled()) return Level.INFO; else if (logger.isWarnEnabled()) return Level.WARN; else if (logger.isErrorEnabled()) return Level.ERROR; else if (logger.isFatalEnabled()) return Level.FATAL; return Level.DEBUG; }
From source file:net.sf.nmedit.jsynth.clavia.nordmodular.utils.NmUtils.java
public static boolean writePatchSavely(NMPatch patch, File file) { try {// w w w . jav a 2s.c o m writePatch(patch, file); return true; } catch (Exception e) { Log log = LogFactory.getLog(NmUtils.class); if (log.isErrorEnabled()) log.error("could not write patch " + patch + " to file " + file, e); return false; } }
From source file:edu.vt.middleware.ldap.LdapTLSSocketFactory.java
/** * This returns the default SSL socket factory. * * @return <code>SocketFactory</code> */// w w w. j a va2s . com public static SocketFactory getDefault() { final LdapTLSSocketFactory sf = new LdapTLSSocketFactory(); try { sf.initialize(); } catch (IOException e) { final Log logger = LogFactory.getLog(LdapTLSSocketFactory.class); if (logger.isErrorEnabled()) { logger.error("Error loading keystore", e); } } catch (GeneralSecurityException e) { final Log logger = LogFactory.getLog(LdapTLSSocketFactory.class); if (logger.isErrorEnabled()) { logger.error("Error initializing socket factory", e); } } return sf; }
From source file:com.liveneo.plat.utils.StringUtil.java
/** * Encodes a string using algorithm specified in web.xml and return the * resulting encrypted password. If exception, the plain credentials string * is returned/*from ww w. j a va 2s.com*/ * * @param password * Password or other credentials to use in authenticating this * username * @param algorithm * Algorithm used to do the digest * @return encypted password based on the algorithm. */ public static String encodePassword(String password, String algorithm) { if (password == null) { return null; } Log log = LogFactory.getLog(StringUtil.class); byte[] unencodedPassword = password.getBytes(); MessageDigest md = null; try { // first create an instance, given the provider md = MessageDigest.getInstance(algorithm); } catch (Exception e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); if (log.isErrorEnabled()) { log.error(sw.toString()); } return password; } md.reset(); // call the update method one or more times // (useful when you don't know the size of your data, e.g. stream) md.update(unencodedPassword); // now calculate the hash byte[] encodedPassword = md.digest(); StringBuffer buf = new StringBuffer(); for (int i = 0; i < encodedPassword.length; i++) { if ((encodedPassword[i] & 0xff) < 0x10) { buf.append("0"); } buf.append(Long.toString(encodedPassword[i] & 0xff, 16)); } return buf.toString(); }
From source file:fedora.server.security.servletfilters.Base.java
public final void showThrowable(Throwable th, Log log, String msg) { if (log.isErrorEnabled()) { if (msg != null) { log.error(msg);/*w w w .j ava 2 s. com*/ } log.error(th); log.error(th.getMessage()); if (th.getCause() != null) { log.error(th.getCause().getMessage()); } th.printStackTrace(); } }
From source file:net.sf.nmedit.jtheme.image.ToolkitImageResource.java
@Override public Image getImage(int width, int height) { if (!(imageInitialized)) { imageInitialized = true;/*from w w w . j a va 2 s.com*/ try { image = ImageIO.read(getEnsureResolvedURL()); } catch (IOException e) { Log log = LogFactory.getLog(getClass()); if (log.isErrorEnabled()) log.error("getImage() failed", e); } } return image; }
From source file:hadoopInstaller.logging.CompositeLog.java
@Override public boolean isErrorEnabled() { boolean enabled = true; for (Log log : this.logs) { enabled = enabled && log.isErrorEnabled(); }/*from w w w.j a v a 2s.c o m*/ return enabled; }
From source file:com.microsoft.tfs.client.common.framework.command.TeamExplorerLogCommandFinishedCallback.java
@Override public void onCommandFinished(final ICommand command, IStatus status) { /*/*from w ww. j a v a2 s. com*/ * Team Explorer ("private") logging. Map IStatus severity to commons * logging severity iff the severity is greater than the configured * tfsLogMinimumSeverity. */ if (status.getSeverity() >= minimumSeverity) { /* * UncaughtCommandExceptionStatus is a TeamExplorerStatus, which * does a silly trick: it makes the exception it was given * accessible only through a non-standard method. This helps when * displaying the status to the user in a dialog, but prevents the * platform logger from logging stack traces, so fix it up here. * * The right long term fix is to ditch TeamExplorerStatus entirely. */ if (status instanceof TeamExplorerStatus) { status = ((TeamExplorerStatus) status).toNormalStatus(); } /* * Don't have a static Log for this class, because then the errors * show up as coming from this class, which is not correct. Instead, * get the logger for the class the errors originated from. Note * that this is not a particularly expensive operation - it looks up * the classname in a hashmap. This should be more than suitable for * a command finished error handler. */ final Log log = LogFactory.getLog(CommandHelpers.unwrapCommand(command).getClass()); if (status.getSeverity() == IStatus.ERROR && log.isErrorEnabled()) { log.error(CommandFinishedCallbackHelpers.getMessageForStatus(status), status.getException()); } else if (status.getSeverity() == IStatus.WARNING && log.isWarnEnabled()) { log.error(CommandFinishedCallbackHelpers.getMessageForStatus(status), status.getException()); } else if (status.getSeverity() == IStatus.INFO && log.isInfoEnabled()) { log.info(CommandFinishedCallbackHelpers.getMessageForStatus(status), status.getException()); } else if (status.getSeverity() == IStatus.CANCEL && log.isInfoEnabled()) { log.info(CommandFinishedCallbackHelpers.getMessageForStatus(status), status.getException()); } else if (status.getSeverity() != IStatus.OK && log.isDebugEnabled()) { log.debug(CommandFinishedCallbackHelpers.getMessageForStatus(status), status.getException()); } else if (log.isTraceEnabled()) { log.trace(CommandFinishedCallbackHelpers.getMessageForStatus(status), status.getException()); } } }
From source file:io.netty.logging.CommonsLoggerTest.java
@Test public void testIsErrorEnabled() { Log mock = createStrictMock(Log.class); expect(mock.isErrorEnabled()).andReturn(true); replay(mock);/*from w ww.j ava 2s . c o m*/ InternalLogger logger = new CommonsLogger(mock, "foo"); assertTrue(logger.isErrorEnabled()); verify(mock); }