• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Level类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FormulaError类代码示例发布时间:2022-05-23
下一篇:
Java JavaElementComparator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap