List of usage examples for org.apache.commons.logging Log isDebugEnabled
boolean isDebugEnabled();
From source file:com.activegrid.runtime.data.util.DataServiceUtils.java
public static Object loadById(Object originalInstance, Session session, DataServiceMetaData metaData, Log logger) { if (originalInstance == null) { throw new IllegalArgumentException("instance to reload cannot be null"); }/* w w w .ja v a 2s . c o m*/ Class<?> clazz = originalInstance.getClass(); String s = metaData.getIdPropertyName(clazz); Serializable id = (Serializable) objectAccess.getProperty(originalInstance, s); Object rtn = session.get(getEntityClass(clazz), id); if (logger != null && logger.isDebugEnabled()) { logger.debug("reloadById: " + ObjectUtils.getId(originalInstance) + " " + s + ":" + id); } return rtn; }
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 {/* w ww .ja v a 2 s . c o m*/ return log.isTraceEnabled(); } }
From source file:it.cnr.icar.eric.client.ui.thin.OutputExceptions.java
/** * Log exceptions and display them to user in a consistent fashion. * * @param log Log where error or warning should be output * @param logMsg Context message to log with t * @param displayMsg Context message to display to user with t * @param t Throwable to log about and optionally display * @param display Output information about this Throwable on page? * @param warning If true, log warning rather than error *///from w w w .j av a 2 s .c o m private static void display(Log log, String logMsg, String displayMsg, Throwable t, boolean display, boolean warning) { // When not given a Msg, should we provide context for cause? boolean needContext = (null != t.getMessage() && null != t.getCause()); // Log a fair amount of information unconditionally if (null == logMsg && null != displayMsg) { logMsg = displayMsg; } if (log.isDebugEnabled()) { // Include full traceback in logging output if (null == logMsg) { if (warning) { log.warn(t.toString(), t); } else { log.error(t.toString(), t); } } else { if (warning) { log.warn(logMsg, t); } else { log.error(logMsg, t); } } } else { if (null == logMsg) { if (needContext) { if (warning) { log.warn(t.toString()); } else { log.error(t.toString()); } } } else { if (warning) { log.warn(logMsg); } else { log.error(logMsg); } } if (warning) { log.error(getCause(t, true)); } else { log.error(getCause(t, true)); } } // Conditionally display a subset of the above information to the user if (display) { FacesContext context = FacesContext.getCurrentInstance(); FacesMessage.Severity severity = (warning ? FacesMessage.SEVERITY_ERROR : FacesMessage.SEVERITY_WARN); if (null == displayMsg && null != logMsg) { displayMsg = logMsg; } if (null == displayMsg) { if (needContext) { context.addMessage(null, new FacesMessage(severity, goodMessage(t), null)); } } else { context.addMessage(null, new FacesMessage(severity, displayMsg, null)); } context.addMessage(null, new FacesMessage(severity, getCause(t, false), null)); } }
From source file:jp.terasoluna.fw.batch.util.BatchUtil.java
/** * ??//from www . ja v a 2s. com * @param stat TransactionStatus * @param savepoint ? * @param log Log */ public static void releaseSavepoint(TransactionStatus stat, Object savepoint, Log log) { if (log != null && log.isDebugEnabled()) { logDebug(log, LogId.DAL025048, stat); } stat.releaseSavepoint(savepoint); if (log != null && log.isDebugEnabled()) { logDebug(log, LogId.DAL025049, stat); } }
From source file:jp.terasoluna.fw.batch.util.BatchUtil.java
/** * ??????/*from w w w .j ava 2 s. c om*/ * @param stat TransactionStatus * @param savepoint ? * @param log Log */ public static void rollbackSavepoint(TransactionStatus stat, Object savepoint, Log log) { if (log != null && log.isDebugEnabled()) { logDebug(log, LogId.DAL025050, stat); } stat.rollbackToSavepoint(savepoint); if (log != null && log.isDebugEnabled()) { logDebug(log, LogId.DAL025051, stat); } }
From source file:jp.terasoluna.fw.batch.util.BatchUtil.java
/** * ?? ???/*from w ww .j av a2s. c o m*/ * @param tran PlatformTransactionManager * @param stat TransactionStatus * @param log Log */ public static void commitTransaction(PlatformTransactionManager tran, TransactionStatus stat, Log log) { if (log != null && log.isDebugEnabled()) { logDebug(log, LogId.DAL025037, stat); } if (tran != null && stat != null) { tran.commit(stat); } if (log != null && log.isDebugEnabled()) { logDebug(log, LogId.DAL025038, stat); } }
From source file:jp.terasoluna.fw.batch.util.BatchUtil.java
/** * ????/*ww w .j a v a 2s . c om*/ * @param tran ? * @param stat TransactionStatus * @param log Log */ public static void rollbackTransaction(PlatformTransactionManager tran, TransactionStatus stat, Log log) { if (log != null && log.isDebugEnabled()) { logDebug(log, LogId.DAL025052, stat); } if (tran != null && stat != null && !stat.isCompleted()) { tran.rollback(stat); } if (log != null && log.isDebugEnabled()) { logDebug(log, LogId.DAL025053, stat); } }
From source file:jp.terasoluna.fw.batch.util.BatchUtil.java
/** * ???/* www . java2s.c om*/ * @param tran PlatformTransactionManager * @param stat TransactionStatus * @param log Log */ public static void endTransaction(PlatformTransactionManager tran, TransactionStatus stat, Log log) { if (log != null && log.isDebugEnabled()) { logDebug(log, LogId.DAL025040, stat); } if (tran != null && stat != null && !stat.isCompleted()) { tran.rollback(stat); } if (log != null && log.isDebugEnabled()) { logDebug(log, LogId.DAL025041, stat); } }
From source file:jp.terasoluna.fw.batch.util.BatchUtil.java
/** * ??/* ww w . j av a 2s .c om*/ * @param stat TransactionStatus * @param log Log * @return Object ? */ public static Object setSavepoint(TransactionStatus stat, Log log) { if (log != null && log.isDebugEnabled()) { logDebug(log, LogId.DAL025046, stat); } Object savepoint = stat.createSavepoint(); if (log != null && log.isDebugEnabled()) { logDebug(log, LogId.DAL025047, stat); } return savepoint; }
From source file:edu.vt.middleware.crypt.CryptProvider.java
/** * <p>This finds a <code>KeyFactory</code> using the known providers and the * supplied algorithm parameter.</p> * * @param algorithm <code>String</code> name * * @return <code>KeyFactory</code> * * @throws CryptException if the algorithm is not available from any * provider or if the provider is not available in the environment */// w ww .ja va2 s. c o m public static KeyFactory getKeyFactory(final String algorithm) throws CryptException { final Log logger = LogFactory.getLog(CryptProvider.class); KeyFactory kf = null; for (int i = 0; i < providers.length; i++) { try { kf = KeyFactory.getInstance(algorithm, providers[i]); } catch (NoSuchAlgorithmException e) { if (logger.isDebugEnabled()) { logger.debug("Could not find algorithm " + algorithm + " in " + providers[i]); } } catch (NoSuchProviderException e) { if (logger.isDebugEnabled()) { logger.debug("Could not find provider " + providers[i]); } } finally { if (kf != null) { break; } } } if (kf == null) { try { kf = KeyFactory.getInstance(algorithm); } catch (NoSuchAlgorithmException e) { if (logger.isDebugEnabled()) { logger.debug("Could not find algorithm " + algorithm); } throw new CryptException(e.getMessage()); } } return kf; }