当前位置: 首页>>代码示例>>Java>>正文


Java Level类代码示例

本文整理汇总了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);
	});
}
 
开发者ID:SemanticRecord,项目名称:talaan,代码行数:17,代码来源:SemanticLoggerTest.java

示例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);
	});
}
 
开发者ID:SemanticRecord,项目名称:talaan,代码行数:22,代码来源:SemanticLoggerTest.java

示例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()));
}
 
开发者ID:zalando,项目名称:problem-spring-web,代码行数:13,代码来源:AdviceTraitLoggingTest.java

示例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));
}
 
开发者ID:zalando,项目名称:problem-spring-web,代码行数:14,代码来源:AdviceTraitLoggingTest.java

示例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());
}
 
开发者ID:codice,项目名称:imaging-nitf,代码行数:30,代码来源:TreCollectionTest.java

示例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);
}
 
开发者ID:dasfoo,项目名称:delern,代码行数:7,代码来源:FirebaseServerRule.java

示例8: initClass

import uk.org.lidalia.slf4jext.Level; //导入依赖的package包/类
@BeforeClass
public static void initClass() {
	TestLoggerFactory.getInstance().setPrintLevel(Level.INFO);
}
 
开发者ID:SemanticRecord,项目名称:talaan,代码行数:5,代码来源:SemanticLoggerTest.java

示例9: initClass

import uk.org.lidalia.slf4jext.Level; //导入依赖的package包/类
@BeforeClass
public static void initClass() {
	TestLoggerFactory.getInstance().setPrintLevel(Level.DEBUG);
}
 
开发者ID:SemanticRecord,项目名称:talaan,代码行数:5,代码来源:SemanticLoggerConfigTest.java

示例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;
}
 
开发者ID:sfleiter,项目名称:cdi-interceptors,代码行数:60,代码来源:LoggingInterceptor.java


注:本文中的uk.org.lidalia.slf4jext.Level类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。