当前位置: 首页>>代码示例>>Java>>正文


Java Logger.isWarnEnabled方法代码示例

本文整理汇总了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);
}
 
开发者ID:xipki,项目名称:xitk,代码行数:17,代码来源:LogUtil.java

示例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());
  }
}
 
开发者ID:apache,项目名称:incubator-ratis,代码行数:19,代码来源:LogUtils.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-ratis,代码行数:21,代码来源:LogUtils.java

示例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.");
  }
}
 
开发者ID:apache,项目名称:incubator-ratis,代码行数:26,代码来源:JavaUtils.java

示例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;
}
 
开发者ID:fchenxi,项目名称:easyhbase,代码行数:22,代码来源:LoggerUtils.java

示例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;
}
 
开发者ID:tenable,项目名称:Tenable.io-SDK-for-Java,代码行数:15,代码来源:LoggerHelper.java

示例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;
}
 
开发者ID:kwon37xi,项目名称:slf4j-lambda,代码行数:41,代码来源:LambdaLoggerUtils.java

示例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);
	}
}
 
开发者ID:allianzit,项目名称:ait-platform,代码行数:14,代码来源:AitLogger.java

示例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);
        }
    }
}
 
开发者ID:mingzuozhibi,项目名称:mzzb-server,代码行数:28,代码来源:AutoRunConfig.java

示例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());
    }
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:6,代码来源:LogUtil.java

示例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();
        }
    }
}
 
开发者ID:gzxishan,项目名称:OftenPorter,代码行数:72,代码来源:PortExecutor.java

示例12: consoleWarn

import org.slf4j.Logger; //导入方法依赖的package包/类
public static void consoleWarn(Logger logger, ScriptObjectMirror args) {
    if (logger.isWarnEnabled()) {
        logger.warn(logMessage(args));
    }
}
 
开发者ID:line,项目名称:centraldogma,代码行数:6,代码来源:Polyfills.java

示例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());
    }
}
 
开发者ID:yu199195,项目名称:happylifeplat-tcc,代码行数:6,代码来源:LogUtil.java

示例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);
    }
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:12,代码来源:LogUtil.java


注:本文中的org.slf4j.Logger.isWarnEnabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。