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));
}
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);
}
}
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();
}
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);
}
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);
}
}
Aggregations