Java Code Examples for org.slf4j.Logger#isErrorEnabled()
The following examples show how to use
org.slf4j.Logger#isErrorEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Slf4jSessionLogger.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
@Override public boolean shouldLog(int level, String category){ Logger logger = getLogger(category); LogLevel logLevel = getLogLevel(level); switch (logLevel) { case TRACE: return logger.isTraceEnabled(); case DEBUG: return logger.isDebugEnabled(); case INFO: return logger.isInfoEnabled(); case WARN: return logger.isWarnEnabled(); case ERROR: return logger.isErrorEnabled(); default: return true; } }
Example 2
Source File: AlbianLoggerService.java From Albianj2 with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public <T extends Exception> void errorAndThrow(String loggerName, Class<T> cls, String eInfo, String format, Object... values) throws RuntimeException { Logger logger = getLogger(loggerName); if (null == logger) return; if (logger.isErrorEnabled()) { String id = AlbianServiceRouter.getLogIdService().makeLoggerId(); String msg = getErrorMsg(format, values); String tMsg = String.format("%s | %s.", id, msg); logger.error(tMsg); Class[] clss = new Class[]{String.class}; Object[] vars = new Object[]{"Error:" + id + "," + eInfo}; T throwObject = null; try { throwObject = (T) AlbianReflect.newInstance(cls, clss, vars); } catch (Exception e1) { throw new RuntimeException(e1); } if (null != throwObject) throw new RuntimeException(throwObject); } }
Example 3
Source File: LoggerWrap.java From elk-reasoner with Apache License 2.0 | 6 votes |
public static boolean isEnabledFor(Logger logger, LogLevel level) { switch (level) { case TRACE: return logger.isTraceEnabled(); case DEBUG: return logger.isDebugEnabled(); case INFO: return logger.isInfoEnabled(); case WARN: return logger.isWarnEnabled(); case ERROR: return logger.isErrorEnabled(); } return false; }
Example 4
Source File: LoggerUtils.java From pinpoint with Apache License 2.0 | 6 votes |
public static int getLoggerLevel(Logger logger) { if (logger == null) { throw new NullPointerException("logger"); } if (logger.isTraceEnabled()) { return TRACE_LEVEL; } if (logger.isDebugEnabled()) { return DEBUG_LEVEL; } if (logger.isInfoEnabled()) { return INFO_LEVEL; } if (logger.isWarnEnabled()) { return WARN_LEVEL; } if (logger.isErrorEnabled()) { return ERROR_LEVEL; } return DISABLE_LEVEL; }
Example 5
Source File: AlbianLoggerService.java From Albianj2 with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public <T extends Exception> void errorAndThrow(String loggerName, T e, String format, Object... values) throws RuntimeException { Logger logger = getLogger(loggerName); if (null == logger) return; if (logger.isErrorEnabled()) { logger.error(getErrorMsg(e, format, values)); throw new RuntimeException(e); } }
Example 6
Source File: LogUtil.java From Lottor with MIT License | 5 votes |
public static void error(Logger logger, String format, Supplier<Object>... supplier) { if (logger.isErrorEnabled()) { String[] o = new String[supplier.length]; for (int i = 0; i < supplier.length; i++) { o[i] = Objects.toString(supplier[i].get()); } logger.info(format, o); } }
Example 7
Source File: AlbianLoggerService2.java From Albianj2 with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void flush3(Logger logger, AlbianLoggerLevel level, String ctx) { switch (level) { case Debug: if (logger.isDebugEnabled()) { logger.debug(ctx); return; } case Info: if (logger.isInfoEnabled()) { logger.info(ctx); return; } case Warn: if (logger.isWarnEnabled()) { logger.warn(ctx); return; } case Error: if (logger.isErrorEnabled()) { logger.error(ctx); return; } case Mark: if (logger.isTraceEnabled()) { logger.trace(ctx); return; } default: if (logger.isInfoEnabled()) { logger.info(ctx); return; } } return; }
Example 8
Source File: RntbdReporter.java From azure-cosmosdb-java with MIT License | 5 votes |
public static void reportIssueUnless( Logger logger, boolean predicate, Object subject, String format, Object... arguments ) { if (!predicate && logger.isErrorEnabled()) { doReportIssue(logger, subject, format, arguments); } }
Example 9
Source File: LogUtils.java From aries-jax-rs-whiteboard with Apache License 2.0 | 5 votes |
public static Consumer<Object> ifErrorEnabled( Logger log, Supplier<String> message) { return o -> { if (log.isErrorEnabled()) { log.error(message.get(), o); } }; }
Example 10
Source File: LambdaLoggerUtils.java From slf4j-lambda with Apache License 2.0 | 5 votes |
/** * check if log level is enabled in the underlying logger * * @param underlyingLogger real Slf4j Logger implementation * @param logLevel log level * @param marker marker * @return true if log level is enabled or false. */ public static boolean isLogLevelEnabled(Logger underlyingLogger, Level logLevel, Marker marker) { switch (logLevel) { case TRACE: if (marker == null) { return underlyingLogger.isTraceEnabled(); } return underlyingLogger.isTraceEnabled(marker); case DEBUG: if (marker == null) { return underlyingLogger.isDebugEnabled(); } return underlyingLogger.isDebugEnabled(marker); case INFO: if (marker == null) { return underlyingLogger.isInfoEnabled(); } return underlyingLogger.isInfoEnabled(marker); case WARN: if (marker == null) { return underlyingLogger.isWarnEnabled(); } return underlyingLogger.isWarnEnabled(marker); case ERROR: if (marker == null) { return underlyingLogger.isErrorEnabled(); } return underlyingLogger.isErrorEnabled(marker); default: break; } return false; }
Example 11
Source File: Slf4jLoggingHandler.java From qpid-broker-j with Apache License 2.0 | 4 votes |
@Override public boolean isEnabled(final Logger logger) { return logger.isErrorEnabled(); }
Example 12
Source File: LogUtil.java From Raincat with GNU Lesser General Public License v3.0 | 4 votes |
public static void error(Logger logger, Supplier<Object> supplier) { if (logger.isErrorEnabled()) { logger.error(Objects.toString(supplier.get())); } }
Example 13
Source File: LogUtil.java From Raincat with GNU Lesser General Public License v3.0 | 4 votes |
public static void error(Logger logger, String format, Supplier<Object> supplier) { if (logger.isErrorEnabled()) { logger.error(format, supplier.get()); } }
Example 14
Source File: RntbdReporter.java From azure-cosmosdb-java with MIT License | 4 votes |
public static void reportIssue(Logger logger, Object subject, String format, Object... arguments) { if (logger.isErrorEnabled()) { doReportIssue(logger, subject, format, arguments); } }
Example 15
Source File: LogUtil.java From Lottor with MIT License | 4 votes |
public static void error(Logger logger, Supplier<Object> supplier) { if (logger.isErrorEnabled()) { logger.error(Objects.toString(supplier.get())); } }
Example 16
Source File: LogUtils.java From datakernel with Apache License 2.0 | 4 votes |
@Override protected boolean isEnabled(Logger logger) { return logger.isErrorEnabled(); }
Example 17
Source File: LogUtil.java From hmily with Apache License 2.0 | 2 votes |
/** * Error. * * @param logger the logger * @param format the format * @param supplier the supplier */ public static void error(Logger logger, String format, Supplier<Object> supplier) { if (logger.isErrorEnabled()) { logger.error(format, supplier.get()); } }
Example 18
Source File: LogUtil.java From myth with Apache License 2.0 | 2 votes |
/** * Error. * * @param logger the logger * @param format the format * @param supplier the supplier */ public static void error(Logger logger, String format, Supplier<Object> supplier) { if (logger.isErrorEnabled()) { logger.error(format, supplier.get()); } }
Example 19
Source File: LogUtil.java From myth with Apache License 2.0 | 2 votes |
/** * Error. * * @param logger the logger * @param supplier the supplier */ public static void error(Logger logger, Supplier<Object> supplier) { if (logger.isErrorEnabled()) { logger.error(Objects.toString(supplier.get())); } }
Example 20
Source File: LogUtil.java From AsuraFramework with Apache License 2.0 | 2 votes |
/** * error level * @param logger * @param s * @param objs */ public static void error(Logger logger,String s,Object... objs){ if(logger.isErrorEnabled()){ logger.error(s,objs); } }