Search in sources :

Example 1 with Level

use of java.util.logging.Level in project buck by facebook.

the class XctoolOutputParsing method testStatusMessageForStatusEvent.

public static Optional<TestStatusMessage> testStatusMessageForStatusEvent(StatusEvent statusEvent) {
    if (statusEvent.message == null || statusEvent.level == null) {
        LOG.warn("Ignoring invalid status (message or level is null): %s", statusEvent);
        return Optional.empty();
    }
    Level level;
    switch(statusEvent.level) {
        case "Verbose":
            level = Level.FINER;
            break;
        case "Debug":
            level = Level.FINE;
            break;
        case "Info":
            level = Level.INFO;
            break;
        case "Warning":
            level = Level.WARNING;
            break;
        case "Error":
            level = Level.SEVERE;
            break;
        default:
            LOG.warn("Ignoring invalid status (unknown level %s)", statusEvent.level);
            return Optional.empty();
    }
    long timeMillis = (long) (statusEvent.timestamp * TimeUnit.SECONDS.toMillis(1));
    return Optional.of(TestStatusMessage.of(statusEvent.message, level, timeMillis));
}
Also used : Level(java.util.logging.Level)

Example 2 with Level

use of java.util.logging.Level in project buck by facebook.

the class JUnitRunner method run.

@Override
public void run() throws Throwable {
    Level stdOutLogLevel = Level.INFO;
    Level stdErrLogLevel = Level.WARNING;
    String unparsedStdOutLogLevel = System.getProperty(STD_OUT_LOG_LEVEL_PROPERTY);
    String unparsedStdErrLogLevel = System.getProperty(STD_ERR_LOG_LEVEL_PROPERTY);
    if (unparsedStdOutLogLevel != null) {
        stdOutLogLevel = Level.parse(unparsedStdOutLogLevel);
    }
    if (unparsedStdErrLogLevel != null) {
        stdErrLogLevel = Level.parse(unparsedStdErrLogLevel);
    }
    for (String className : testClassNames) {
        final Class<?> testClass = Class.forName(className);
        List<TestResult> results = new ArrayList<>();
        RecordingFilter filter = new RecordingFilter();
        if (mightBeATestClass(testClass)) {
            JUnitCore jUnitCore = new JUnitCore();
            Runner suite = new Computer().getSuite(createRunnerBuilder(), new Class<?>[] { testClass });
            Request request = Request.runner(suite);
            request = request.filterWith(filter);
            jUnitCore.addListener(new TestListener(results, stdOutLogLevel, stdErrLogLevel));
            jUnitCore.run(request);
        }
        // Combine the results with the tests we filtered out
        List<TestResult> actualResults = combineResults(results, filter.filteredOut);
        writeResult(className, actualResults);
    }
}
Also used : Runner(org.junit.runner.Runner) JUnitCore(org.junit.runner.JUnitCore) ArrayList(java.util.ArrayList) Computer(org.junit.runner.Computer) Request(org.junit.runner.Request) Level(java.util.logging.Level)

Example 3 with Level

use of java.util.logging.Level in project LogisticsPipes by RS485.

the class RequestLogFormator method format.

@Override
public String format(LogRecord record) {
    StringBuilder msg = new StringBuilder();
    msg.append(dateFormat.format(Long.valueOf(record.getMillis())));
    Level lvl = record.getLevel();
    if (lvl == Level.FINEST) {
        msg.append(" [FINEST] ");
    } else if (lvl == Level.FINER) {
        msg.append(" [FINER] ");
    } else if (lvl == Level.FINE) {
        msg.append(" [FINE] ");
    } else if (lvl == Level.INFO) {
        msg.append(" [INFO] ");
    } else if (lvl == Level.WARNING) {
        msg.append(" [WARNING] ");
    } else if (lvl == Level.SEVERE) {
        msg.append(" [SEVERE] ");
    } else if (lvl == Level.SEVERE) {
        msg.append(" [" + lvl.getLocalizedName() + "] ");
    }
    if (record.getLoggerName() != null && !record.getLoggerName().equals("LogisticsPipes|Request") && !record.getLoggerName().equals("")) {
        msg.append("[" + record.getLoggerName() + "] ");
    }
    msg.append(record.getMessage());
    msg.append(RequestLogFormator.LINE_SEPARATOR);
    Throwable thr = record.getThrown();
    if (thr != null) {
        StringWriter thrDump = new StringWriter();
        thr.printStackTrace(new PrintWriter(thrDump));
        msg.append(thrDump.toString());
    }
    return msg.toString();
}
Also used : StringWriter(java.io.StringWriter) Level(java.util.logging.Level) PrintWriter(java.io.PrintWriter)

Example 4 with Level

use of java.util.logging.Level in project buck by facebook.

the class LogLevelTypeCoercerTest method coercesValidLogLevel.

@Test
public void coercesValidLogLevel() throws CoerceFailedException {
    Level expected = Level.WARNING;
    Level actual = coercer.coerce(createCellRoots(filesystem), filesystem, pathFromRoot, "WARNING");
    assertEquals(expected, actual);
}
Also used : Level(java.util.logging.Level) Test(org.junit.Test)

Example 5 with Level

use of java.util.logging.Level in project jersey by jersey.

the class LoggingFeature method createLoggingFilter.

private LoggingInterceptor createLoggingFilter(FeatureContext context, RuntimeType runtimeType) {
    Map properties = context.getConfiguration().getProperties();
    String filterLoggerName = CommonProperties.getValue(properties, runtimeType == RuntimeType.SERVER ? LOGGING_FEATURE_LOGGER_NAME_SERVER : LOGGING_FEATURE_LOGGER_NAME_CLIENT, CommonProperties.getValue(properties, LOGGING_FEATURE_LOGGER_NAME, DEFAULT_LOGGER_NAME));
    String filterLevel = CommonProperties.getValue(properties, runtimeType == RuntimeType.SERVER ? LOGGING_FEATURE_LOGGER_LEVEL_SERVER : LOGGING_FEATURE_LOGGER_LEVEL_CLIENT, CommonProperties.getValue(context.getConfiguration().getProperties(), LOGGING_FEATURE_LOGGER_LEVEL, DEFAULT_LOGGER_LEVEL));
    Verbosity filterVerbosity = CommonProperties.getValue(properties, runtimeType == RuntimeType.SERVER ? LOGGING_FEATURE_VERBOSITY_SERVER : LOGGING_FEATURE_VERBOSITY_CLIENT, CommonProperties.getValue(properties, LOGGING_FEATURE_VERBOSITY, DEFAULT_VERBOSITY));
    int filterMaxEntitySize = CommonProperties.getValue(properties, runtimeType == RuntimeType.SERVER ? LOGGING_FEATURE_MAX_ENTITY_SIZE_SERVER : LOGGING_FEATURE_MAX_ENTITY_SIZE_CLIENT, CommonProperties.getValue(properties, LOGGING_FEATURE_MAX_ENTITY_SIZE, DEFAULT_MAX_ENTITY_SIZE));
    Level loggerLevel = Level.parse(filterLevel);
    if (runtimeType == RuntimeType.SERVER) {
        return new ServerLoggingFilter(filterLogger != null ? filterLogger : Logger.getLogger(filterLoggerName), level != null ? level : loggerLevel, verbosity != null ? verbosity : filterVerbosity, maxEntitySize != null ? maxEntitySize : filterMaxEntitySize);
    } else {
        return new ClientLoggingFilter(filterLogger != null ? filterLogger : Logger.getLogger(filterLoggerName), level != null ? level : loggerLevel, verbosity != null ? verbosity : filterVerbosity, maxEntitySize != null ? maxEntitySize : filterMaxEntitySize);
    }
}
Also used : Level(java.util.logging.Level) Map(java.util.Map)

Aggregations

Level (java.util.logging.Level)317 Logger (java.util.logging.Logger)65 IOException (java.io.IOException)28 Test (org.junit.Test)28 Handler (java.util.logging.Handler)27 LogRecord (java.util.logging.LogRecord)27 Map (java.util.Map)18 ArrayList (java.util.ArrayList)17 CommandLine (org.apache.commons.cli.CommandLine)15 CommandLineParser (org.apache.commons.cli.CommandLineParser)13 DefaultParser (org.apache.commons.cli.DefaultParser)13 Options (org.apache.commons.cli.Options)13 ParseException (org.apache.commons.cli.ParseException)13 List (java.util.List)12 ConsoleHandler (java.util.logging.ConsoleHandler)12 HashMap (java.util.HashMap)11 SystemConfig (com.twitter.heron.common.config.SystemConfig)10 Config (com.sun.enterprise.config.serverbeans.Config)9 BlockingQueueHandler (fish.payara.nucleus.notification.BlockingQueueHandler)9 PrintWriter (java.io.PrintWriter)9