Java Code Examples for org.slf4j.Logger.isErrorEnabled()

The following are Jave code examples for showing how to use isErrorEnabled() of the org.slf4j.Logger class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: xitk   File: LogUtil.java   View Source Code Vote up 6 votes
public static void error(Logger log, Throwable th) {
    if (!log.isErrorEnabled()) {
        return;
    }

    // this operation is expensive, hence don't abuse it.
    StackTraceElement[] traces = Thread.currentThread().getStackTrace();
    if (traces.length > 2) {
        StackTraceElement trace = traces[2];
        log.error("({} {}), {}: {}", trace.getMethodName(), trace.getLineNumber(),
                th.getClass().getName(), getMessage(th));
    } else {
        log.error("{}: {}", th.getClass().getName(), getMessage(th));
    }
    log.debug("Exception", th);
}
 
Example 2
Project: xitk   File: LogUtil.java   View Source Code Vote up 6 votes
public static void error(Logger log, Throwable th, String msg) {
    if (!log.isErrorEnabled()) {
        return;
    }

    // this operation is expensive, hence don't abuse it.
    StackTraceElement[] traces = Thread.currentThread().getStackTrace();
    if (traces.length > 2) {
        StackTraceElement trace = traces[2];
        log.error("({} {}) {}, {}: {}", trace.getMethodName(), trace.getLineNumber(), msg,
                th.getClass().getName(), getMessage(th));
    } else {
        log.error("{}, {}: {}", msg, th.getClass().getName(), getMessage(th));
    }
    log.debug(msg, th);
}
 
Example 3
Project: easyhbase   File: LoggerUtils.java   View Source Code Vote up 6 votes
public static int getLoggerLevel(Logger logger) {
    if (logger == null) {
        throw new NullPointerException("logger must not be null");
    }
    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 4
Project: slf4j-lambda   File: LambdaLoggerUtils.java   View Source Code Vote up 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 5
Project: talchain   File: BlockHeaderRule.java   View Source Code Vote up 5 votes
public boolean validateAndLog(BlockHeader header, Logger logger) {
    ValidationResult result = validate(header);
    if (!result.success && logger.isErrorEnabled()) {
        logger.warn("{} invalid {}", getEntityClass(), result.error);
    }
    return result.success;
}
 
Example 6
Project: rskj   File: AbstractValidationRule.java   View Source Code Vote up 5 votes
public void logErrors(Logger logger) {
    if (logger.isErrorEnabled()) {
        for (String msg : errors) {
            logger.warn("{} invalid: {}", getEntityClass().getSimpleName(), msg);
        }
    }
}
 
Example 7
Project: Tenable.io-SDK-for-Java   File: LoggerHelper.java   View Source Code Vote up 5 votes
public static LogLevel getLogLevel( Logger logger ) {
    if( logger.isTraceEnabled() )
        return LogLevel.TRACE;
    else if( logger.isDebugEnabled() )
        return LogLevel.DEBUG;
    else if( logger.isInfoEnabled() )
        return LogLevel.INFO;
    else if( logger.isWarnEnabled() )
        return LogLevel.WARN;
    else if( logger.isErrorEnabled() )
        return LogLevel.ERROR;

    return LogLevel.NONE;
}
 
Example 8
Project: AppCoins-ethereumj   File: BlockHeaderRule.java   View Source Code Vote up 5 votes
public boolean validateAndLog(BlockHeader header, Logger logger) {
    ValidationResult result = validate(header);
    if (!result.success && logger.isErrorEnabled()) {
        logger.warn("{} invalid {}", getEntityClass(), result.error);
    }
    return result.success;
}
 
Example 9
Project: ait-platform   File: AitLogger.java   View Source Code Vote up 5 votes
/**
 * error
 * @param logger
 * @param message
 * @param params
 */

public static void error(Logger logger, String message, Object... params) {
	
	if (logger.isErrorEnabled()) {
		logger.error(message, params);
	}
}
 
Example 10
Project: happylifeplat-transaction   File: LogUtil.java   View Source Code Vote up 4 votes
public static void error(Logger logger,String format,Supplier<Object> supplier){
    if(logger.isErrorEnabled()){
        logger.error(format,supplier.get());
    }
}
 
Example 11
Project: happylifeplat-transaction   File: LogUtil.java   View Source Code Vote up 4 votes
public static void error(Logger logger,Supplier<Object> supplier){
    if(logger.isErrorEnabled()){
        logger.error(Objects.toString(supplier.get()));
    }
}
 
Example 12
Project: talchain   File: DependentBlockHeaderRule.java   View Source Code Vote up 4 votes
public void logErrors(Logger logger) {
    if (logger.isErrorEnabled())
        for (String msg : errors) {
            logger.warn("{} invalid: {}", getEntityClass().getSimpleName(), msg);
        }
}
 
Example 13
Project: centraldogma   File: Polyfills.java   View Source Code Vote up 4 votes
public static void consoleError(Logger logger, ScriptObjectMirror args) {
    if (logger.isErrorEnabled()) {
        logger.error(logMessage(args));
    }
}
 
Example 14
Project: happylifeplat-tcc   File: LogUtil.java   View Source Code Vote up 4 votes
public static void error(Logger logger, String format, Supplier<Object> supplier) {
    if (logger.isErrorEnabled()) {
        logger.error(format, supplier.get());
    }
}
 
Example 15
Project: happylifeplat-tcc   File: LogUtil.java   View Source Code Vote up 4 votes
public static void error(Logger logger, Supplier<Object> supplier) {
    if (logger.isErrorEnabled()) {
        logger.error(Objects.toString(supplier.get()));
    }
}
 
Example 16
Project: myth   File: LogUtil.java   View Source Code Vote up 4 votes
public static void error(Logger logger, String format, Supplier<Object> supplier) {
    if (logger.isErrorEnabled()) {
        logger.error(format, supplier.get());
    }
}
 
Example 17
Project: myth   File: LogUtil.java   View Source Code Vote up 4 votes
public static void error(Logger logger, Supplier<Object> supplier) {
    if (logger.isErrorEnabled()) {
        logger.error(Objects.toString(supplier.get()));
    }
}
 
Example 18
Project: AppCoins-ethereumj   File: DependentBlockHeaderRule.java   View Source Code Vote up 4 votes
public void logErrors(Logger logger) {
    if (logger.isErrorEnabled())
        for (String msg : errors) {
            logger.warn("{} invalid: {}", getEntityClass().getSimpleName(), msg);
        }
}
 
Example 19
Project: asura   File: LogUtil.java   View Source Code Vote up 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);
    }
}