本文整理汇总了Java中org.slf4j.Logger.isWarnEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.isWarnEnabled方法的具体用法?Java Logger.isWarnEnabled怎么用?Java Logger.isWarnEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.slf4j.Logger
的用法示例。
在下文中一共展示了Logger.isWarnEnabled方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: warn
import org.slf4j.Logger; //导入方法依赖的package包/类
public static void warn(Logger log, Throwable th, String msg) {
if (!log.isWarnEnabled()) {
return;
}
// this operation is expensive, hence don't abuse it.
StackTraceElement[] traces = Thread.currentThread().getStackTrace();
if (traces.length > 2) {
StackTraceElement trace = traces[2];
log.warn("({} {}) {}, {}: {}", trace.getMethodName(), trace.getLineNumber(), msg,
th.getClass().getName(), getMessage(th));
} else {
log.warn("{}, {}: {}", msg, th.getClass().getName(), getMessage(th));
}
log.debug(msg, th);
}
示例2: runAndLog
import org.slf4j.Logger; //导入方法依赖的package包/类
static <THROWABLE extends Throwable> void runAndLog(
Logger log, CheckedRunnable<THROWABLE> op, Supplier<String> opName)
throws THROWABLE {
try {
op.run();
} catch (Throwable t) {
if (log.isTraceEnabled()) {
log.trace("Failed to " + opName.get(), t);
} else if (log.isWarnEnabled()){
log.warn("Failed to " + opName.get() + ": " + t);
}
throw t;
}
if (log.isTraceEnabled()) {
log.trace("Successfully ran " + opName.get());
}
}
示例3: supplyAndLog
import org.slf4j.Logger; //导入方法依赖的package包/类
static <OUTPUT, THROWABLE extends Throwable> OUTPUT supplyAndLog(
Logger log, CheckedSupplier<OUTPUT, THROWABLE> supplier, Supplier<String> name)
throws THROWABLE {
final OUTPUT output;
try {
output = supplier.get();
} catch (Throwable t) {
if (log.isTraceEnabled()) {
log.trace("Failed to " + name.get(), t);
} else if (log.isWarnEnabled()){
log.warn("Failed to " + name.get() + ": " + t);
}
throw (THROWABLE)t;
}
if (log.isTraceEnabled()) {
log.trace("Successfully supplied " + name.get());
}
return output;
}
示例4: attempt
import org.slf4j.Logger; //导入方法依赖的package包/类
/** Attempt to wait the given condition to return true multiple times. */
static void attempt(
BooleanSupplier condition, int numAttempts, long sleepMs, String name, Logger log)
throws InterruptedException {
Objects.requireNonNull(condition, "condition == null");
Preconditions.assertTrue(numAttempts > 0, () -> "numAttempts = " + numAttempts + " <= 0");
Preconditions.assertTrue(sleepMs >= 0L, () -> "sleepMs = " + sleepMs + " < 0");
for(int i = 1; i <= numAttempts; i++) {
if (condition.getAsBoolean()) {
return;
}
if (log != null && log.isWarnEnabled()) {
log.warn("FAILED " + name + " attempt #" + i + "/" + numAttempts
+ ": sleep " + sleepMs + "ms and then retry.");
}
if (sleepMs > 0) {
Thread.sleep(sleepMs);
}
}
if (!condition.getAsBoolean()) {
throw new IllegalStateException("Failed " + name + " for " + numAttempts + " attempts.");
}
}
示例5: getLoggerLevel
import org.slf4j.Logger; //导入方法依赖的package包/类
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;
}
示例6: getLogLevel
import org.slf4j.Logger; //导入方法依赖的package包/类
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;
}
示例7: isLogLevelEnabled
import org.slf4j.Logger; //导入方法依赖的package包/类
/**
* 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;
}
示例8: warn
import org.slf4j.Logger; //导入方法依赖的package包/类
/**
* warn
* @param logger
* @param message
* @param params
*/
public static void warn(Logger logger, String message, Object... params) {
if (logger.isWarnEnabled()) {
logger.warn(message, params);
}
}
示例9: fetchAmazonDiscsData
import org.slf4j.Logger; //导入方法依赖的package包/类
private void fetchAmazonDiscsData(int retry) {
Logger logger = LoggerFactory.getLogger(AutoRunConfig.class);
if (retry == 0) {
if (logger.isWarnEnabled()) {
logger.warn("fetching amazon discs data failed");
}
} else {
if (logger.isInfoEnabled()) {
logger.info("fetching amazon discs data ({})", retry);
}
try {
amazonDiscsSpider.fetch();
} catch (IOException e) {
if (logger.isDebugEnabled()) {
logger.debug("fetching amazon discs data throw an error", e);
}
if (retry > 0) {
fetchSakuraSpeedData(retry - 1);
} else {
return;
}
}
if (logger.isInfoEnabled()) {
logger.info("fetched amazon discs data ({})", retry);
}
}
}
示例10: warn
import org.slf4j.Logger; //导入方法依赖的package包/类
public static void warn(Logger logger,String format,Supplier<Object> supplier){
if(logger.isWarnEnabled()){
logger.warn(format,supplier.get());
}
}
示例11: doRequest
import org.slf4j.Logger; //导入方法依赖的package包/类
public void doRequest(PreRequest req, WRequest request, WResponse response, boolean isInnerRequest)
{
WObjectImpl wObject = null;
try
{
PorterOfFun funPort = req.funPort;
Porter classPort = req.classPort;
Context context = req.context;
InnerContextBridge innerContextBridge = context.innerContextBridge;
UrlDecoder.Result result = req.result;
if (!isInnerRequest && funPort.getMethodPortIn()
.getPortFunType() == PortFunType.INNER)
{
exNotFoundClassPort(request, response, innerContextBridge.responseWhenException);
return;
}
wObject = new WObjectImpl(pName, result, request, response, context, isInnerRequest);
IAttributeFactory attributeFactory = iAttributeFactory;
Object originRequest = request.getOriginalRequest();
if (originRequest != null && originRequest instanceof IAttributeFactory)
{
attributeFactory = (IAttributeFactory) originRequest;
}
wObject.setIAttribute(attributeFactory);
if (funPort.getMethodPortIn().getTiedType().isRest())
{
wObject.restValue = result.funTied();
}
ParamSource paramSource = getParamSource(wObject, classPort, funPort);
wObject.setParamSource(paramSource);
//全局通过检测
dealtOfGlobalCheck(context, funPort, wObject, innerContextBridge, result);
} catch (Exception e)
{
Throwable ex = getCause(e);
response.toErr();
Logger LOGGER = logger(null);
if (LOGGER.isWarnEnabled())
{
LOGGER.warn(ex.getMessage(), ex);
}
if (responseWhenException)
{
JResponse jResponse = new JResponse(ResultCode.EXCEPTION);
jResponse.setDescription(WPTool.getMessage(ex));
try
{
response.write(jResponse);
} catch (IOException e1)
{
LOGGER.warn(e1.getMessage(), e1);
}
}
close(response);
} finally
{
if (wObject != null)
{
wObject.invokeAfterInvokeListeners();
}
}
}
示例12: consoleWarn
import org.slf4j.Logger; //导入方法依赖的package包/类
public static void consoleWarn(Logger logger, ScriptObjectMirror args) {
if (logger.isWarnEnabled()) {
logger.warn(logMessage(args));
}
}
示例13: warn
import org.slf4j.Logger; //导入方法依赖的package包/类
public static void warn(Logger logger, String format, Supplier<Object> supplier) {
if (logger.isWarnEnabled()) {
logger.warn(format, supplier.get());
}
}
示例14: warn
import org.slf4j.Logger; //导入方法依赖的package包/类
/**
* warn level
* @param logger
* @param s
* @param objs
*/
public static void warn(Logger logger,String s,Object... objs){
if(logger.isWarnEnabled()){
logger.warn(s, objs);
}
}