Java Code Examples for org.slf4j.event.Level#WARN
The following examples show how to use
org.slf4j.event.Level#WARN .
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: Slf4jEventSender.java From cxf with Apache License 2.0 | 6 votes |
/** * Override this to easily change the logging level etc. */ protected void performLogging(Logger log, Marker marker, String logMessage) { if (loggingLevel == Level.INFO) { log.info(marker, logMessage); } else if (loggingLevel == Level.DEBUG) { log.debug(marker, logMessage); } else if (loggingLevel == Level.ERROR) { log.error(marker, logMessage); } else if (loggingLevel == Level.TRACE) { log.trace(marker, logMessage); } else if (loggingLevel == Level.WARN) { log.warn(marker, logMessage); } else { log.info(marker, logMessage); } }
Example 2
Source File: HyenaExceptionHandler.java From hyena with Apache License 2.0 | 5 votes |
private void logException(BaseException exp) { if (exp.getLogLevel() == Level.ERROR) { logger.error(exp.getMessage(), exp); } else if (exp.getLogLevel() == Level.WARN) { logger.warn(exp.getMessage(), exp); } else if (exp.getLogLevel() == Level.INFO) { logger.info(exp.getMessage(), exp); } else if (exp.getLogLevel() == Level.DEBUG) { logger.debug(exp.getMessage(), exp); } else if (exp.getLogLevel() == Level.TRACE) { logger.trace(exp.getMessage(), exp); } else { logger.error(exp.getMessage(), exp); } }
Example 3
Source File: MessageContainerBase.java From rqueue with Apache License 2.0 | 5 votes |
void log(Level level, String msg, Throwable t, Object... objects) { if (level == Level.DEBUG && !log.isDebugEnabled()) { return; } if (level == Level.ERROR && !log.isErrorEnabled()) { return; } if (level == Level.INFO && !log.isInfoEnabled()) { return; } if (level == Level.WARN && !log.isWarnEnabled()) { return; } Object[] objects1 = new Object[objects.length + 1 + (t == null ? 0 : 1)]; System.arraycopy(objects, 0, objects1, 1, objects.length); objects1[0] = groupName; if (t != null) { objects1[objects1.length - 1] = t; } String txt = "[{}] " + msg; switch (level) { case INFO: log.info(txt, objects1); break; case WARN: log.warn(txt, objects1); break; case DEBUG: log.debug(txt, objects1); break; case ERROR: log.error(txt, objects1); break; default: log.trace(txt, objects1); } }
Example 4
Source File: StdErrorReporter.java From linstor-server with GNU General Public License v3.0 | 5 votes |
@Override public Level getCurrentLogLevel() { Level level = null; // no logging, aka OFF org.slf4j.Logger crtLogger = mainLogger; if (crtLogger.isTraceEnabled()) { level = Level.TRACE; } else if (crtLogger.isDebugEnabled()) { level = Level.DEBUG; } else if (crtLogger.isInfoEnabled()) { level = Level.INFO; } else if (crtLogger.isWarnEnabled()) { level = Level.WARN; } else if (crtLogger.isErrorEnabled()) { level = Level.ERROR; } return level; }
Example 5
Source File: LinstorParsingUtils.java From linstor-server with GNU General Public License v3.0 | 5 votes |
public static Level asLogLevel(String logLevelRef) { Level logLevel; if (logLevelRef == null || logLevelRef.isEmpty()) { throw new ApiRcException( ApiCallRcImpl.simpleEntry( ApiConsts.FAIL_INVLD_CONF, "Given loglevel is null." ) ); } switch (logLevelRef.toUpperCase()) { case "ERROR": logLevel = Level.ERROR; break; case "WARN": logLevel = Level.WARN; break; case "INFO": logLevel = Level.INFO; break; case "DEBUG": logLevel = Level.DEBUG; break; case "TRACE": logLevel = Level.TRACE; break; default: throw new ApiRcException( ApiCallRcImpl.simpleEntry( ApiConsts.FAIL_INVLD_CONF, "Given loglevel '" + logLevelRef + "' is invalid" ) ); } return logLevel; }
Example 6
Source File: RequestLogger.java From google-ads-java with Apache License 2.0 | 5 votes |
private static void logAtLevel(Logger logger, Level level, String format, Object... argList) { if (level == Level.INFO) { logger.info(format, argList); } else if (level == Level.WARN) { logger.warn(format, argList); } else if (level == Level.DEBUG) { logger.debug(format, argList); } else { throw new IllegalStateException("Unexpected log level: " + level); } }
Example 7
Source File: LogAlertTest.java From dss with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void warnLogAlertTest() { Status exception = new Status(EXCEPTION_MESSAGE); CallbackExceptionAlertHandler callback = new CallbackExceptionAlertHandler(); LogHandler<Status> logExceptionAlertHandler = new LogHandler<Status>(Level.WARN); CompositeAlertHandler<Status> alertHandler = new CompositeAlertHandler<Status>(Arrays.asList(callback, logExceptionAlertHandler)); CustomStatusAlert exceptionAlert = new CustomStatusAlert(alertHandler); exceptionAlert.alert(exception); assertTrue(callback.called); }
Example 8
Source File: HyenaAssert.java From hyena with Apache License 2.0 | 4 votes |
public static void equals(String expect, String actual, String message) { if (!StringUtils.equals(expect, actual)) { throw new HyenaServiceException(message, Level.WARN); } }
Example 9
Source File: PointFreezeStrategy.java From hyena with Apache License 2.0 | 4 votes |
@Override public PointOpResult processPoint(PointUsage usage, PointCache pointCache) { PointVo curPoint = pointCache.getPoint(); if (DecimalUtils.lt(curPoint.getAvailable(), usage.getPoint())) { log.warn("no enough available point. usage = {}, curPoint = {}", usage, curPoint); throw new HyenaNoPointException("no enough available point", Level.WARN); } curPoint.setSeqNum(curPoint.getSeqNum() + 1) .setAvailable(curPoint.getAvailable().subtract(usage.getPoint())) .setFrozen(curPoint.getFrozen().add(usage.getPoint())); PointPo point2Update = new PointPo(); point2Update.setAvailable(curPoint.getAvailable()) .setFrozen(curPoint.getFrozen()).setSeqNum(curPoint.getSeqNum()) .setId(curPoint.getId()); PointLogPo pointLog = this.pointBuilder.buildPointLog(PointOpType.FREEZE, usage, curPoint); BigDecimal gap = usage.getPoint(); BigDecimal cost = DecimalUtils.ZERO; List<PointRecLogDto> recLogs = new ArrayList<>(); LoopResult recLogsRet = this.freezePointLoop(usage, pointCache, pointLog, gap); gap = gap.subtract(recLogsRet.getDelta()); cost = cost.add(recLogsRet.getDeltaCost()); recLogs.addAll(recLogsRet.getRecLogs()); log.debug("gap = {}", gap); if (gap.compareTo(DecimalUtils.ZERO) != 0) { log.warn("no enough available point! gap = {}", gap); } if (DecimalUtils.gt(cost, DecimalUtils.ZERO)) { pointLog.setDeltaCost(cost).setFrozenCost(pointLog.getFrozenCost().add(cost)); curPoint.setFrozenCost(curPoint.getFrozenCost().add(cost)); point2Update.setFrozenCost(curPoint.getFrozenCost()); } pointFlowService.updatePoint(usage.getType(), point2Update); pointFlowService.updatePointRec(usage.getType(), recLogsRet.getRecList4Update()); pointFlowService.addFreezeOrderRec(usage.getType(), recLogsRet.getForList()); pointFlowService.addFlow(usage, pointLog, recLogs); pointCache.setUpdateTime(new Date()); //return curPoint; PointOpResult ret = new PointOpResult(); BeanUtils.copyProperties(curPoint, ret); ret.setOpPoint(recLogsRet.getDelta()) .setOpCost(recLogsRet.getDeltaCost()); return ret; }
Example 10
Source File: PointUnfreezeStrategy.java From hyena with Apache License 2.0 | 4 votes |
@Override public PointOpResult processPoint(PointUsage usage, PointCache pointCache) { PointPo curPoint = pointCache.getPoint(); if (curPoint.getFrozen().compareTo(usage.getPoint()) < 0) { log.warn("no enough frozen point. usage = {}, curPoint = {}", usage, curPoint); throw new HyenaNoPointException("no enough frozen point", Level.WARN); } HyenaAssert.isTrue(curPoint.getFrozen().compareTo(usage.getPoint()) >= 0, HyenaConstants.RES_CODE_NO_ENOUGH_POINT, "no enough frozen point"); curPoint.setSeqNum(curPoint.getSeqNum() + 1) .setAvailable(curPoint.getAvailable().add(usage.getPoint())) .setFrozen(curPoint.getFrozen().subtract(usage.getPoint())); var point2Update = new PointPo(); point2Update.setAvailable(curPoint.getAvailable()) .setFrozen(curPoint.getFrozen()) .setSeqNum(curPoint.getSeqNum()) .setId(curPoint.getId()); PointLogPo pointLog = this.pointBuilder.buildPointLog(PointOpType.UNFREEZE, usage, curPoint); LoopResult recLogsRet = null; if (Boolean.TRUE.equals(usage.getUnfreezeByOrderNo())) { recLogsRet = this.unfreezeByOrderNo(usage, pointCache, pointLog); } else { recLogsRet = this.unfreezePointLoop(usage, pointCache, pointLog, usage.getPoint()); } if (recLogsRet.getDeltaCost().compareTo(DecimalUtils.ZERO) > 0) { pointLog.setDeltaCost(recLogsRet.getDeltaCost()) .setFrozenCost(pointLog.getFrozenCost().subtract(recLogsRet.getDeltaCost())); curPoint.setFrozenCost(curPoint.getFrozenCost().subtract(recLogsRet.getDeltaCost())); point2Update.setFrozenCost(curPoint.getFrozenCost()); } PointOpResult ret = new PointOpResult(); BeanUtils.copyProperties(curPoint, ret); ret.setOpPoint(recLogsRet.getDelta()) .setOpCost(recLogsRet.getDeltaCost()) .setLogs(List.of(PointLogDto.build(pointLog))); if (usage.isDoUpdate()) { pointFlowService.updatePoint(usage.getType(), point2Update); pointFlowService.updatePointRec(usage.getType(), recLogsRet.getRecList4Update()); if (CollectionUtils.isNotEmpty(recLogsRet.getForList())) { pointFlowService.closeFreezeOrderRec(usage.getType(), recLogsRet.getForList()); } pointFlowService.addFlow(usage, pointLog, recLogsRet.getRecLogs()); } else { ret.getUpdateQ().setPoint(point2Update); ret.getUpdateQ().getLogs().add(pointLog); ret.getUpdateQ().getRecList().addAll(recLogsRet.getRecList4Update()); if (CollectionUtils.isNotEmpty(recLogsRet.getForList())) { ret.getUpdateQ().getFoList().addAll(recLogsRet.getForList()); } ret.getUpdateQ().getRecLogs().addAll(recLogsRet.getRecLogs()); } return ret; }
Example 11
Source File: RequestLogger.java From google-ads-java with Apache License 2.0 | 4 votes |
private static boolean isLevelEnabled(Level logLevel, Logger logger) { return (logLevel == Level.INFO && logger.isInfoEnabled()) || (logLevel == Level.WARN && logger.isWarnEnabled()) || (logLevel == Level.DEBUG && logger.isDebugEnabled()); }
Example 12
Source File: LoggingInterceptor.java From google-ads-java with Apache License 2.0 | 4 votes |
private static Level getSummaryLevel(Status status) { return isSuccess(status) ? Level.INFO : Level.WARN; }
Example 13
Source File: LogHandler.java From dss with GNU Lesser General Public License v2.1 | 4 votes |
public LogHandler() { this(Level.WARN); }
Example 14
Source File: StreamLogger.java From gocd with Apache License 2.0 | 4 votes |
static StreamConsumer getWarnLogger(Logger log) { return new StreamLogger(log, Level.WARN); }