本文整理汇总了Java中uk.org.lidalia.slf4jext.Level类的典型用法代码示例。如果您正苦于以下问题:Java Level类的具体用法?Java Level怎么用?Java Level使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Level类属于uk.org.lidalia.slf4jext包,在下文中一共展示了Level类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: simpleLogEntry
import uk.org.lidalia.slf4jext.Level; //导入依赖的package包/类
@Test
public void simpleLogEntry() {
logger.loggerCreated(elapsedTime.stop());
assertSingleEvent(event -> {
assertThat(event.getLevel()).isEqualTo(Level.INFO);
assertThat(event.getCreatingLogger().getName()).isEqualTo(SampleLoggerInterface.class.getName());
String msg = "event=loggerCreated, elapsedTime={}";
String eventMessage = event.getMessage();
assertThat(eventMessage).isEqualTo(msg);
ImmutableList<Object> args = event.getArguments();
assertThat(args.size()).isEqualTo(1);
assertThat(args.get(0)).isEqualTo(elapsedTime);
});
}
示例2: testThrowable
import uk.org.lidalia.slf4jext.Level; //导入依赖的package包/类
@Test
public void testThrowable() {
elapsedTime.reset().start();
RuntimeException ex = new RuntimeException("Expected exception message");
try {
throw ex;
} catch (Exception e) {
logger.problemSavingRecord(1, elapsedTime.stop(), e);
}
assertSingleEvent(event -> {
String msg = "event=problemSavingRecord, eventId=INVOICEAPP-1001, invoiceId={}, elapsedTime={}";
String eventMessage = event.getMessage();
assertThat(eventMessage).isEqualTo(msg);
assertThat(event.getLevel()).isEqualTo(Level.ERROR);
Optional<Throwable> throwableOpt = event.getThrowable();
assertThat(throwableOpt.isPresent()).isEqualTo(true);
assertThat(throwableOpt.get()).isEqualTo(ex);
});
}
示例3: setUpClass
import uk.org.lidalia.slf4jext.Level; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
// The slf4j-test logger causes a huge amount of spam to be output for these tests. Disable for these tests, then re-enable in tearDown().
logPrintLevelAtStart = TestLoggerFactory.getInstance().getPrintLevel();
TestLoggerFactory.getInstance().setPrintLevel(Level.WARN);
System.setProperty(StreamingAsyncHttpClient.SHOULD_LOG_BAD_MESSAGES_AFTER_REQUEST_FINISHES_SYSTEM_PROP_KEY, "true");
int backendPort = ComponentTestUtils.findFreePort();
backendServerConfig = new BackendServerConfig(backendPort);
backendServer = new Server(backendServerConfig);
backendServer.startup();
int intermediateRouterPort = ComponentTestUtils.findFreePort();
intermediateRouterServerConfig = new RouterServerConfig(intermediateRouterPort, backendPort);
intermediateRouterServer = new Server(intermediateRouterServerConfig);
intermediateRouterServer.startup();
int edgeRouterPort = ComponentTestUtils.findFreePort();
edgeRouterServerConfig = new RouterServerConfig(edgeRouterPort, intermediateRouterPort);
edgeRouterServer = new Server(edgeRouterServerConfig);
edgeRouterServer.startup();
}
开发者ID:Nike-Inc,项目名称:riposte,代码行数:24,代码来源:VerifyResponseHttpStatusCodeHandlingRfcCorrectnessComponentTest.java
示例4: shouldLog4xxAsWarn
import uk.org.lidalia.slf4jext.Level; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("data")
void shouldLog4xxAsWarn(final Status status) {
assumeTrue(status.getStatusCode() / 100 == 4);
unit.create(status, new NoHandlerFoundException("GET", "/", new HttpHeaders()), mock(NativeWebRequest.class));
final LoggingEvent event = getOnlyElement(log.getLoggingEvents());
assertThat(event.getLevel(), is(Level.WARN));
assertThat(event.getMessage(), is("{}: {}"));
assertThat(event.getArguments(), contains(getReasonPhrase(status), "No handler found for GET /"));
assertThat(event.getThrowable().orNull(), is(nullValue()));
}
示例5: shouldLog5xxAsError
import uk.org.lidalia.slf4jext.Level; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("data")
void shouldLog5xxAsError(final Status status) {
assumeTrue(status.getStatusCode() / 100 == 5);
final IOException throwable = new IOException();
unit.create(status, throwable, mock(NativeWebRequest.class));
final LoggingEvent event = getOnlyElement(log.getLoggingEvents());
assertThat(event.getLevel(), is(Level.ERROR));
assertThat(event.getMessage(), is(getReasonPhrase(status)));
assertThat(event.getArguments(), emptyIterable());
assertThat(event.getThrowable().orNull(), is(throwable));
}
示例6: testGracefulRecovery
import uk.org.lidalia.slf4jext.Level; //导入依赖的package包/类
@Test
public void testGracefulRecovery() throws NitfFormatException {
LOGGER.clear();
String treString = "ENGRDA00058LAIR 00113majorVersion00010001A1NA00000002AENGRDA00058LAIR 00112majorVersion00010001A1NA000000011";
InputStream inputStream = new ByteArrayInputStream(treString.getBytes(StandardCharsets.ISO_8859_1));
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
NitfReader nitfReader = new NitfInputStreamReader(bufferedInputStream);
TreCollectionParser treCollectionParser = new TreCollectionParser();
TreCollection treCollection = treCollectionParser.parse(nitfReader, 138, TreSource.ImageExtendedSubheaderData);
assertEquals(2, treCollection.getTREs().size());
Tre tre0 = treCollection.getTREs().get(0);
assertNotNull(tre0.getName());
assertEquals(0, tre0.getEntries().size());
assertNotNull(tre0.getRawData());
Tre tre1 = treCollection.getTREs().get(1);
assertNotNull(tre1.getName());
assertEquals(3, tre1.getEntries().size());
assertNull(tre1.getRawData());
com.google.common.collect.ImmutableList<LoggingEvent> loggingEvents = LOGGER.getLoggingEvents();
assertEquals(2, loggingEvents.size());
assertEquals(Level.WARN, loggingEvents.get(0).getLevel());
assertEquals("Failed to parse TRE {}. See debug log for exception information.", loggingEvents.get(0).getMessage());
assertEquals(1, loggingEvents.get(0).getArguments().size());
assertEquals("ENGRDA", loggingEvents.get(0).getArguments().get(0));
assertEquals(Level.DEBUG, loggingEvents.get(1).getLevel());
assertEquals(NumberFormatException.class, loggingEvents.get(1).getThrowable().get().getClass());
}
示例7: FirebaseServerRule
import uk.org.lidalia.slf4jext.Level; //导入依赖的package包/类
public FirebaseServerRule() {
super();
findDependencies(new File(System.getProperty("user.dir")));
RxJavaPlugins.setErrorHandler(e -> LOGGER.error("Undeliverable RxJava error", e));
TestLoggerFactory.getInstance().setPrintLevel(Level.DEBUG);
}
示例8: initClass
import uk.org.lidalia.slf4jext.Level; //导入依赖的package包/类
@BeforeClass
public static void initClass() {
TestLoggerFactory.getInstance().setPrintLevel(Level.INFO);
}
示例9: initClass
import uk.org.lidalia.slf4jext.Level; //导入依赖的package包/类
@BeforeClass
public static void initClass() {
TestLoggerFactory.getInstance().setPrintLevel(Level.DEBUG);
}
示例10: loggingMethodInvoke
import uk.org.lidalia.slf4jext.Level; //导入依赖的package包/类
/**
* Logging method invoke.
*
* @param ctx
* the invocation context
* @return the result object
* @throws Exception
* only rethrows original exception from intercepted method call
*/
@AroundInvoke
public Object loggingMethodInvoke(final InvocationContext ctx) throws Exception {
Logger logger = LoggerFactory.getLogger(ctx.getTarget().getClass()
.getName());
Logging annotation = getAnnotation(ctx.getTarget(), ctx.getMethod(), Logging.class);
Level level;
int maximumCount = annotation.logItemLimit();
boolean measureDuration = annotation.measureDuration();
StringBuilder sb;
long start = currentTimeMillis(measureDuration);
long duration;
Object result;
try {
result = ctx.proceed();
level = annotation.standardLogLevel();
if (logger.isEnabled(level)) {
duration = currentTimeMillis(measureDuration) - start;
sb = getCallString(ctx, maximumCount);
sb.append(" returns ");
stringTransformer.transform(sb, result, maximumCount);
appendDuration(sb, measureDuration, duration);
logger.log(level, sb.toString());
}
} catch (Exception e) {
boolean isSevere = isExceptionSevere(e, annotation);
boolean logStackTrace = true;
if (isSevere) {
level = annotation.severeExceptionLogLevel();
} else {
level = annotation.standardLogLevel();
if (!annotation.logStackTraceAtStandardLevel()) {
logStackTrace = false;
}
}
if (logger.isEnabled(level)) {
duration = currentTimeMillis(measureDuration) - start;
sb = getCallString(ctx, maximumCount);
sb.append(" caused {}");
appendDuration(sb, measureDuration, duration);
if (logStackTrace) {
logger.log(level, sb.toString(), e, e);
} else {
logger.log(level, sb.toString(), e.toString());
}
}
throw e;
}
return result;
}