List of usage examples for org.apache.commons.logging Log isErrorEnabled
boolean isErrorEnabled();
From source file:fr.gouv.vitam.utils.logging.CommonsLoggerTest.java
@Test public void testIsErrorEnabled() { final Log mock = createStrictMock(Log.class); expect(mock.isErrorEnabled()).andReturn(true); replay(mock);/* w w w .j a v a2 s . c o m*/ final VitamLogger logger = new CommonsLogger(mock, "foo"); assertTrue(logger.isErrorEnabled()); verify(mock); }
From source file:net.sf.nmedit.jtheme.image.SVGImageResource.java
private void readData() { InputStream source = null;// w w w . j a v a 2 s . co m try { byte[] tmp = new byte[1024]; source = new BufferedInputStream(createInputStream()); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); int size; while ((size = source.read(tmp)) != -1) { buffer.write(tmp, 0, size); } svgData = new String(buffer.toByteArray()); } catch (IOException e) { Log log = LogFactory.getLog(getClass()); if (log.isErrorEnabled()) log.error(getClass().getName() + ".readData() failed", e); } finally { try { if (source != null) source.close(); } catch (IOException e) { // ignore } } }
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the given message to the log at the error level. If the log level is not enabled, this method does * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned. * * @param log the log where the messages will go * @param key the resource bundle key name * @param varargs arguments to help fill in the resource bundle message * * @return if the message was logged, a non-<code>null</code> Msg object is returned *///from w ww . ja v a 2 s . c o m public static Msg error(Log log, String key, Object... varargs) { if (log.isErrorEnabled()) { Msg msg = Msg.createMsg(key, varargs); log.error((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg); return msg; } return null; }
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the given message to the log at the error level. If the log level is not enabled, this method does * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned. * * @param log the log where the messages will go * @param locale the locale to determine what bundle to use * @param key the resource bundle key name * @param varargs arguments to help fill in the resource bundle message * * @return if the message was logged, a non-<code>null</code> Msg object is returned *//*from w w w . j a v a2 s .co m*/ public static Msg error(Log log, Locale locale, String key, Object... varargs) { if (log.isErrorEnabled()) { Msg msg = Msg.createMsg(locale, key, varargs); log.error((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg); return msg; } return null; }
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the given message to the log at the error level. If the log level is not enabled, this method does * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned. * * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p> * * @param log the log where the messages will go * @param throwable the throwable associated with the log message * @param key the resource bundle key name * @param varargs arguments to help fill in the resource bundle message * * @return if the message was logged, a non-<code>null</code> Msg object is returned *//*from www . j a v a 2s. c o m*/ public static Msg error(Log log, Throwable throwable, String key, Object... varargs) { if (log.isErrorEnabled()) { Msg msg = Msg.createMsg(key, varargs); logErrorWithThrowable(log, key, msg, throwable); return msg; } return null; }
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the given message to the log at the error level. If the log level is not enabled, this method does * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned. * * @param log the log where the messages will go * @param basename the base name of the resource bundle * @param key the resource bundle key name * @param varargs arguments to help fill in the resource bundle message * * @return if the message was logged, a non-<code>null</code> Msg object is returned *///from w w w . jav a 2s . com public static Msg error(Log log, BundleBaseName basename, String key, Object... varargs) { if (log.isErrorEnabled()) { Msg msg = Msg.createMsg(basename, key, varargs); log.error((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg); return msg; } return null; }
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the given message to the log at the error level. If the log level is not enabled, this method does * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned. * * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p> * * @param log the log where the messages will go * @param throwable the throwable associated with the log message * @param locale the locale to determine what bundle to use * @param key the resource bundle key name * @param varargs arguments to help fill in the resource bundle message * * @return if the message was logged, a non-<code>null</code> Msg object is returned *///w ww . ja v a 2s . co m public static Msg error(Log log, Throwable throwable, Locale locale, String key, Object... varargs) { if (log.isErrorEnabled()) { Msg msg = Msg.createMsg(locale, key, varargs); logErrorWithThrowable(log, key, msg, throwable); return msg; } return null; }
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the given message to the log at the error level. If the log level is not enabled, this method does * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned. * * @param log the log where the messages will go * @param basename the base name of the resource bundle * @param locale the locale to determine what bundle to use * @param key the resource bundle key name * @param varargs arguments to help fill in the resource bundle message * * @return if the message was logged, a non-<code>null</code> Msg object is returned *//*from ww w. ja va 2 s .c o m*/ public static Msg error(Log log, BundleBaseName basename, Locale locale, String key, Object... varargs) { if (log.isErrorEnabled()) { Msg msg = Msg.createMsg(basename, locale, key, varargs); log.error((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg); return msg; } return null; }
From source file:com.wavemaker.runtime.data.util.JDBCUtils.java
public static Object runSql(String sql[], String url, String username, String password, String driverClassName, Log logger, boolean isDDL) { Connection con = getConnection(url, username, password, driverClassName); try {/*from w w w .j a v a 2 s. c o m*/ try { con.setAutoCommit(true); } catch (SQLException ex) { throw new DataServiceRuntimeException(ex); } Statement s = con.createStatement(); try { try { for (String stmt : sql) { if (logger != null && logger.isInfoEnabled()) { logger.info("Running " + stmt); } s.execute(stmt); } if (!isDDL) { ResultSet r = s.getResultSet(); List<Object> rtn = new ArrayList<Object>(); while (r.next()) { // getting only the first col is pretty unuseful rtn.add(r.getObject(1)); } return rtn.toArray(new Object[rtn.size()]); } } catch (Exception ex) { if (logger != null && logger.isErrorEnabled()) { logger.error(ex.getMessage()); } throw ex; } } finally { try { s.close(); } catch (Exception ignore) { } } } catch (Exception ex) { if (ex instanceof RuntimeException) { throw (RuntimeException) ex; } else { throw new DataServiceRuntimeException(ex); } } finally { try { con.close(); } catch (Exception ignore) { } } return null; }
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the given message to the log at the error level. If the log level is not enabled, this method does * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned. * * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p> * * @param log the log where the messages will go * @param throwable the throwable associated with the log message * @param basename the base name of the resource bundle * @param key the resource bundle key name * @param varargs arguments to help fill in the resource bundle message * * @return if the message was logged, a non-<code>null</code> Msg object is returned *//*from w w w . j a v a 2s . c o m*/ public static Msg error(Log log, Throwable throwable, BundleBaseName basename, String key, Object... varargs) { if (log.isErrorEnabled()) { Msg msg = Msg.createMsg(basename, key, varargs); logErrorWithThrowable(log, key, msg, throwable); return msg; } return null; }