Java Code Examples for org.slf4j.event.Level#INFO

The following examples show how to use org.slf4j.event.Level#INFO . 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 vote down vote up
/**
 * 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: BaseModuleIntegTestAbstract.java    From estatio with Apache License 2.0 6 votes vote down vote up
protected BaseModuleIntegTestAbstract(
            final ModuleAbstract module,
            final IntrospectionMode introspectionMode) {

    super(new LogConfig(Level.INFO,
            logPrintStream(Level.DEBUG)),

            new ModuleForTesting(
                    module,
                    new GotenbergRenderingFakeModule(),
                    new FakeCommsServiceModule()
            ).withConfigurationProperty(
                SpecificationLoader.CONFIG_PROPERTY_MODE.of(introspectionMode)
            ).withConfigurationProperty(
                "isis.services.eventbus.implementation", "axon"
            )
    );
}
 
Example 3
Source File: HyenaExceptionHandler.java    From hyena with Apache License 2.0 5 votes vote down vote up
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 4
Source File: MessageContainerBase.java    From rqueue with Apache License 2.0 5 votes vote down vote up
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 5
Source File: StdErrorReporter.java    From linstor-server with GNU General Public License v3.0 5 votes vote down vote up
@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 6
Source File: LinstorParsingUtils.java    From linstor-server with GNU General Public License v3.0 5 votes vote down vote up
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 7
Source File: RequestLogger.java    From google-ads-java with Apache License 2.0 5 votes vote down vote up
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 8
Source File: TransformerFactoryBuilderTest.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void infoLogExceptionTest() {
	TransformerFactoryBuilder secureTransformerBuilder = TransformerFactoryBuilder.getSecureTransformerBuilder();
	secureTransformerBuilder.enableFeature("CUSTOM_FEATURE");
	
	CallbackExceptionAlertHandler callback = new CallbackExceptionAlertHandler();
	LogHandler<Status> logExceptionAlertHandler = new LogHandler<Status>(Level.INFO);
	CompositeAlertHandler<Status> alertHandler = new CompositeAlertHandler<Status>(Arrays.asList(callback, logExceptionAlertHandler));

	secureTransformerBuilder.setSecurityExceptionAlert(new CustomStatusAlert(alertHandler));
	
	secureTransformerBuilder.build();
	
	assertTrue(callback.called);
}
 
Example 9
Source File: LiteProcess.java    From liteflow with Apache License 2.0 4 votes vote down vote up
/**
 * 运行任务
 * @throws IOException
 */
public void run() throws IOException {

    if (this.isStarted() || this.isComplete()) {
        throw new IllegalStateException("this process can only be used once");
    }

    try {
        final ProcessBuilder builder = new ProcessBuilder(this.cmd);
        builder.directory(new File(this.workingDir));
        builder.environment().putAll(this.env);
        builder.redirectErrorStream(true);
        this.process = builder.start();
        //获取进程id
        this.processId = processId(this.process);
        if (this.processId == 0) {
            this.logger.info("can not get processId");
        } else {
            this.logger.info("get processId:" + this.processId);
        }

        this.startupLatch.countDown();

        final LogGobbler outputGobbler =
                new LogGobbler(
                        new InputStreamReader(this.process.getInputStream(), StandardCharsets.UTF_8),
                        this.logger, Level.INFO, LOG_BUFFER_LINE);
        final LogGobbler errorGobbler =
                new LogGobbler(
                        new InputStreamReader(this.process.getErrorStream(), StandardCharsets.UTF_8),
                        this.logger, Level.ERROR, LOG_BUFFER_LINE);

        LiteThreadPool.getInstance().execute(outputGobbler);
        LiteThreadPool.getInstance().execute(errorGobbler);
        int exitCode = -1;
        try {
            exitCode = this.process.waitFor();
        } catch (final Throwable e) {
            this.logger.info("process error,exit code is " + exitCode, e);
        }


        //进程退出前,搜集日志
        outputGobbler.awaitCompletion(WAIT_LOG_COLLECT_TIME);
        errorGobbler.awaitCompletion(WAIT_LOG_COLLECT_TIME);

        this.completeLatch.countDown();
        /**
         * 任务运行失败后,通过抛异常来标示
         */
        if (exitCode != 0) {
            final String output = new StringBuilder()
                            .append("info:\n")
                            .append(outputGobbler.getRecentLog())
                            .append("\n\n")
                            .append("error:\n")
                            .append(errorGobbler.getRecentLog())
                            .append("\n").toString();

            throw new ProcessFailureException(exitCode, output);
        }
        this.isSuccess = true;
    } finally {
        IOUtils.closeQuietly(this.process.getInputStream());
        IOUtils.closeQuietly(this.process.getOutputStream());
        IOUtils.closeQuietly(this.process.getErrorStream());
        if(this.startupLatch.getCount() > 0){
            this.startupLatch.countDown();
        }
        if(this.completeLatch.getCount() > 0){
            this.completeLatch.countDown();
        }
    }
}
 
Example 10
Source File: RequestLogger.java    From google-ads-java with Apache License 2.0 4 votes vote down vote up
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 11
Source File: LoggingInterceptor.java    From google-ads-java with Apache License 2.0 4 votes vote down vote up
private static Level getDetailLevel(Status status) {
  return isSuccess(status) ? Level.DEBUG : Level.INFO;
}
 
Example 12
Source File: LoggingInterceptor.java    From google-ads-java with Apache License 2.0 4 votes vote down vote up
private static Level getSummaryLevel(Status status) {
  return isSuccess(status) ? Level.INFO : Level.WARN;
}
 
Example 13
Source File: MyLogger.java    From code-examples with MIT License 4 votes vote down vote up
@LogMessage(level=Level.INFO, message="This is an INFO message.", id=5456)
void logInfoMessage();
 
Example 14
Source File: HttpLoggingPlugin.java    From cukes with Apache License 2.0 4 votes vote down vote up
@Inject
public HttpLoggingPlugin(GlobalWorldFacade world, RestAssuredConfiguration config) {
    this.world = world;
    this.config = config;
    logStream = new LoggerPrintStream(getLogger(world.get(LOGGING_LOGGER_NAME, DEFAULT_LOGGER_NAME)), Level.INFO);
}
 
Example 15
Source File: StreamLogger.java    From gocd with Apache License 2.0 4 votes vote down vote up
static StreamConsumer getInfoLogger(Logger log) {
    return new StreamLogger(log, Level.INFO);
}