private void logDebug(String message, Object...args) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(message, args); } }
@Override public void error( Throwable t, String message, Object... params ) { if (logger.isErrorEnabled()) { logger.error(t, new TextI18n(message), params); } }
protected TikaMimeTypeDetector( Environment environment ) { assert environment != null; this.logger = Logger.getLogger(getClass()); // the extra classpath entry is the package name of the tika extractor, so it can be located inside AS7 (see // RepositoryService) ClassLoader loader = environment.getClassLoader(this, "org.modeshape.extractor.tika"); logger.debug("Initializing mime-type detector..."); initDetector(loader); logger.debug("Successfully initialized detector: {0}", getClass().getName()); }
@Override public void info( String message, Object... params ) { if (logger.isInfoEnabled()) { logger.info(new TextI18n(message), params); } }
@Override public void warn( Throwable t, String message, Object... params ) { if (logger.isWarnEnabled()) { logger.warn(t, new TextI18n(message), params); } }
private String repositoryURLFromParams( Map<?, ?> parameters ) { if (parameters == null) { LOG.debug("The supplied parameters are null"); return null; } Object rawUrl = parameters.get(RepositoryFactory.URL); if (rawUrl == null) { LOG.debug("No parameter found with key: " + RepositoryFactory.URL); return null; } return rawUrl.toString(); }
@Override public Document get( String key ) { LOGGER.debug("reading {0}", key); TransactionStore.TransactionMap<String, Document> txContent = transactionalContent(false); Document result = txContent != null ? txContent.getLatest(key) : persistedContent.get(key); if (LOGGER.isTraceEnabled()) { LOGGER.trace("{0} is {1}", key, result); } return result; }
/** * Return a logger associated with this context. This logger records only those activities within the context and provide a * way to capture the context-specific activities. All log messages are also sent to the system logger, so classes that log * via this mechanism should <i>not</i> also {@link Logger#getLogger(Class) obtain a system logger}. * * @param clazz the class that is doing the logging * @return the logger, named after <code>clazz</code>; never null * @see #getLogger(String) */ public Logger getLogger( Class<?> clazz ) { return Logger.getLogger(clazz); }
public static <T extends Number> void writeHistogramToLog( Logger logger, Histogram<T> histogram, int barLength, String description ) { logger.info(MockI18n.passthrough, description != null ? description : "Histogram:"); List<String> barGraph = histogram.getTextGraph(barLength); for (String line : barGraph) { logger.debug(" " + line); } }
private void closeStream() { try { stream.close(); } catch (IOException e) { LOGGER.error(e, CommonI18n.errorClosingWrappedStream); } } }
@Override public void trace( String message, Object... params ) { logger.trace(message, params); }
@Test public void shouldSupportAskingWhetherLoggingLevelsAreEnabled() { logger.isErrorEnabled(); logger.isWarnEnabled(); logger.isInfoEnabled(); logger.isDebugEnabled(); logger.isTraceEnabled(); }
protected final void warn( I18n message, Object... params ) { logger.warn(message, params); problems.addWarning(message, params); }
@Override public void rollback() throws IllegalStateException, SecurityException, SystemException { if (logger.isTraceEnabled()) { logger.trace("Rolling back transaction '{0}'", id); } super.rollback(); }
@Override public void logout() { try { loggedIn = false; if (loginContext != null) loginContext.logout(); } catch (LoginException le) { LOGGER.info(le, null); } }
@Override public boolean isDebugEnabled() { return logger.isDebugEnabled(); }
@Test public void shouldLogNoMessagesIfLog4jSetToOffLevel() { log4jLogger.setLevel(Level.OFF); logger.error(errorMessageWithNoParameters); logger.warn(warningMessageWithNoParameters); logger.info(infoMessageWithNoParameters); logger.debug("This is a debug message with no parameters"); logger.trace("This is a trace message with no parameters"); assertEquals(false, log.hasEvents()); }
@Override protected Class<?> findClass( String name ) throws ClassNotFoundException { for (ClassLoader delegate : delegates) { try { return delegate.loadClass(name); } catch (ClassNotFoundException e) { LOGGER.debug(e, "Cannot load class using delegate: " + delegate.getClass().toString()); } } return super.findClass(name); }