reactor.util.Logger.isTraceEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(234)

本文整理了Java中reactor.util.Logger.isTraceEnabled()方法的一些代码示例,展示了Logger.isTraceEnabled()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.isTraceEnabled()方法的具体详情如下:
包路径:reactor.util.Logger
类名称:Logger
方法名:isTraceEnabled

Logger.isTraceEnabled介绍

[英]Is the logger instance enabled for the TRACE level?
[中]是否为跟踪级别启用了记录器实例?

代码示例

代码示例来源:origin: spring-cloud/spring-cloud-sleuth

  1. @Override
  2. public void onSubscribe(Subscription subscription) {
  3. if (log.isTraceEnabled()) {
  4. log.trace("On subscribe");
  5. }
  6. this.s = subscription;
  7. try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(this.span)) {
  8. if (log.isTraceEnabled()) {
  9. log.trace("On subscribe - span continued");
  10. }
  11. this.subscriber.onSubscribe(this);
  12. }
  13. }

代码示例来源:origin: spring-cloud/spring-cloud-sleuth

  1. @Override
  2. public void request(long n) {
  3. if (log.isTraceEnabled()) {
  4. log.trace("Request");
  5. }
  6. try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(this.span)) {
  7. if (log.isTraceEnabled()) {
  8. log.trace("Request - continued");
  9. }
  10. this.s.request(n);
  11. // no additional cleaning is required cause we operate on scopes
  12. if (log.isTraceEnabled()) {
  13. log.trace("Request after cleaning. Current span [{}]",
  14. this.tracer.currentSpan());
  15. }
  16. }
  17. }

代码示例来源:origin: spring-cloud/spring-cloud-sleuth

  1. void cleanup() {
  2. if (compareAndSet(false, true)) {
  3. if (log.isTraceEnabled()) {
  4. log.trace("Cleaning up");
  5. }
  6. this.span.finish();
  7. if (log.isTraceEnabled()) {
  8. log.trace("Span closed");
  9. }
  10. if (this.rootSpan != null) {
  11. this.rootSpan.finish();
  12. if (log.isTraceEnabled()) {
  13. log.trace("Closed root span");
  14. }
  15. }
  16. }
  17. }

代码示例来源:origin: reactor/reactor-core

  1. @Test
  2. public void isTraceEnabled() throws Exception {
  3. assertThat(logger.isTraceEnabled()).isTrue();
  4. }

代码示例来源:origin: spring-cloud/spring-cloud-sleuth

  1. @Override
  2. public void cancel() {
  3. try {
  4. if (log.isTraceEnabled()) {
  5. log.trace("Cancel");
  6. }
  7. this.s.cancel();
  8. }
  9. finally {
  10. cleanup();
  11. }
  12. }

代码示例来源:origin: reactor/reactor-core

  1. @Test
  2. public void logErrorUsesDebugWhenFine() {
  3. Level level = Level.FINE;
  4. Mono<String> source = Mono.error(new IllegalStateException("ignored"));
  5. Logger mockLogger = Mockito.mock(Logger.class);
  6. when(mockLogger.isErrorEnabled()).thenReturn(true);
  7. when(mockLogger.isDebugEnabled()).thenReturn(true);
  8. when(mockLogger.isTraceEnabled()).thenReturn(true);
  9. SignalLogger<String> sl = new SignalLogger<>(source, null, level,
  10. false, s -> mockLogger);
  11. sl.onErrorCall().accept(new IllegalStateException("boom"));
  12. verify(mockLogger, never()).isErrorEnabled();
  13. verify(mockLogger, times(1)).isDebugEnabled();
  14. verify(mockLogger, never()).isTraceEnabled();
  15. verify(mockLogger, times(1)).debug(Mockito.anyString(), (Object[]) Mockito.any());
  16. verify(mockLogger, times(1)).debug(Mockito.anyString(), (Throwable) Mockito.any());
  17. verifyNoMoreInteractions(mockLogger);
  18. }

代码示例来源:origin: reactor/reactor-core

  1. @Test
  2. public void logErrorUsesErrorWhenInfo() {
  3. Level level = Level.INFO;
  4. Mono<String> source = Mono.error(new IllegalStateException("ignored"));
  5. Logger mockLogger = Mockito.mock(Logger.class);
  6. when(mockLogger.isErrorEnabled()).thenReturn(true);
  7. when(mockLogger.isDebugEnabled()).thenReturn(true);
  8. when(mockLogger.isTraceEnabled()).thenReturn(true);
  9. SignalLogger<String> sl = new SignalLogger<>(source, null, level,
  10. false, s -> mockLogger);
  11. sl.onErrorCall().accept(new IllegalStateException("boom"));
  12. verify(mockLogger, times(1)).isErrorEnabled();
  13. verify(mockLogger, never()).isDebugEnabled();
  14. verify(mockLogger, never()).isTraceEnabled();
  15. verify(mockLogger, times(1)).error(Mockito.anyString(), (Object[]) Mockito.any());
  16. verify(mockLogger, times(1)).error(Mockito.anyString(), (Throwable) Mockito.any());
  17. verifyNoMoreInteractions(mockLogger);
  18. }

代码示例来源:origin: reactor/reactor-core

  1. @Test
  2. public void logErrorUsesErrorWhenWarning() {
  3. Level level = Level.WARNING;
  4. Mono<String> source = Mono.error(new IllegalStateException("ignored"));
  5. Logger mockLogger = Mockito.mock(Logger.class);
  6. when(mockLogger.isErrorEnabled()).thenReturn(true);
  7. when(mockLogger.isDebugEnabled()).thenReturn(true);
  8. when(mockLogger.isTraceEnabled()).thenReturn(true);
  9. SignalLogger<String> sl = new SignalLogger<>(source, null, level,
  10. false, s -> mockLogger);
  11. sl.onErrorCall().accept(new IllegalStateException("boom"));
  12. verify(mockLogger, times(1)).isErrorEnabled();
  13. verify(mockLogger, never()).isDebugEnabled();
  14. verify(mockLogger, never()).isTraceEnabled();
  15. verify(mockLogger, times(1)).error(Mockito.anyString(), (Object[]) Mockito.any());
  16. verify(mockLogger, times(1)).error(Mockito.anyString(), (Throwable) Mockito.any());
  17. verifyNoMoreInteractions(mockLogger);
  18. }

代码示例来源:origin: reactor/reactor-core

  1. @Test
  2. public void logErrorUsesErrorWhenSevere() {
  3. Level level = Level.SEVERE;
  4. Mono<String> source = Mono.error(new IllegalStateException("ignored"));
  5. Logger mockLogger = Mockito.mock(Logger.class);
  6. when(mockLogger.isErrorEnabled()).thenReturn(true);
  7. when(mockLogger.isDebugEnabled()).thenReturn(true);
  8. when(mockLogger.isTraceEnabled()).thenReturn(true);
  9. SignalLogger<String> sl = new SignalLogger<>(source, null, level,
  10. false, s -> mockLogger);
  11. sl.onErrorCall().accept(new IllegalStateException("boom"));
  12. verify(mockLogger, times(1)).isErrorEnabled();
  13. verify(mockLogger, never()).isDebugEnabled();
  14. verify(mockLogger, never()).isTraceEnabled();
  15. verify(mockLogger, times(1)).error(Mockito.anyString(), (Object[]) Mockito.any());
  16. verify(mockLogger, times(1)).error(Mockito.anyString(), (Throwable) Mockito.any());
  17. verifyNoMoreInteractions(mockLogger);
  18. }

代码示例来源:origin: reactor/reactor-core

  1. @Test
  2. public void traceDismissedInNonVerboseMode() {
  3. Logger log = new Loggers.ConsoleLogger("test", new PrintStream(outContent), new PrintStream(errContent), false);
  4. log.trace("foo");
  5. log.trace("foo", new IllegalArgumentException("foo"));
  6. log.trace("foo {}", "foo");
  7. assertThat(outContent.toString()).doesNotContain("foo");
  8. assertThat(errContent.toString()).doesNotContain("foo");
  9. assertThat(log.isTraceEnabled()).as("isTraceEnabled").isFalse();
  10. }

代码示例来源:origin: reactor/reactor-core

  1. @Test
  2. public void logErrorUsesTraceWhenFinest() {
  3. Level level = Level.FINEST;
  4. demonstrateLogError(); //added to the test suite so that sanity check can be done
  5. Mono<String> source = Mono.error(new IllegalStateException("ignored"));
  6. Logger mockLogger = Mockito.mock(Logger.class);
  7. when(mockLogger.isErrorEnabled()).thenReturn(true);
  8. when(mockLogger.isDebugEnabled()).thenReturn(true);
  9. when(mockLogger.isTraceEnabled()).thenReturn(true);
  10. SignalLogger<String> sl = new SignalLogger<>(source, null, level,
  11. false, s -> mockLogger);
  12. sl.onErrorCall().accept(new IllegalStateException("boom"));
  13. verify(mockLogger, never()).isErrorEnabled();
  14. verify(mockLogger, never()).isDebugEnabled();
  15. verify(mockLogger, times(1)).isTraceEnabled();
  16. verify(mockLogger, times(1)).trace(Mockito.anyString(), (Object[]) Mockito.any());
  17. verify(mockLogger, times(1)).trace(Mockito.anyString(), (Throwable) Mockito.any());
  18. verifyNoMoreInteractions(mockLogger);
  19. }

代码示例来源:origin: spring-cloud/spring-cloud-sleuth

  1. SpanSubscriber(Subscriber<? super T> subscriber, Context ctx, Tracing tracing,
  2. String name) {
  3. this.subscriber = subscriber;
  4. this.tracer = tracing.tracer();
  5. Span root = ctx.getOrDefault(Span.class, this.tracer.currentSpan());
  6. if (log.isTraceEnabled()) {
  7. log.trace("Span from context [{}]", root);
  8. }
  9. this.rootSpan = root;
  10. if (log.isTraceEnabled()) {
  11. log.trace("Stored context root span [{}]", this.rootSpan);
  12. }
  13. this.span = root != null ? this.tracer
  14. .nextSpan(TraceContextOrSamplingFlags.create(root.context())).name(name)
  15. : this.tracer.nextSpan().name(name);
  16. if (log.isTraceEnabled()) {
  17. log.trace("Created span [{}], with name [{}]", this.span, name);
  18. }
  19. this.context = ctx.put(Span.class, this.span);
  20. }

代码示例来源:origin: reactor/reactor-core

  1. public Consumer<? super Throwable> onErrorCall() {
  2. boolean shouldLogAsDebug = level == Level.FINE && log.isDebugEnabled();
  3. boolean shouldLogAsTrace = level == Level.FINEST && log.isTraceEnabled();
  4. boolean shouldLogAsError = level != Level.FINE && level != Level.FINEST && log.isErrorEnabled();
  5. if ((options & ON_ERROR) == ON_ERROR && (shouldLogAsError || shouldLogAsDebug ||

代码示例来源:origin: io.rsocket.rpc/rsocket-rpc-core

  1. @Override
  2. public void request(long n) {
  3. if (log.isTraceEnabled()) {
  4. log.trace("Request");
  5. }
  6. if (log.isTraceEnabled()) {
  7. log.trace("Request - continued");
  8. }
  9. this.s.request(n);
  10. // no additional cleaning is required cause we operate on scopes
  11. if (log.isTraceEnabled()) {
  12. log.trace("Request after cleaning. Current span [{}]", this.tracer.activeSpan());
  13. }
  14. }

代码示例来源:origin: org.springframework.cloud/spring-cloud-sleuth-core

  1. @Override
  2. public void onSubscribe(Subscription subscription) {
  3. if (log.isTraceEnabled()) {
  4. log.trace("On subscribe");
  5. }
  6. this.s = subscription;
  7. try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(this.span)) {
  8. if (log.isTraceEnabled()) {
  9. log.trace("On subscribe - span continued");
  10. }
  11. this.subscriber.onSubscribe(this);
  12. }
  13. }

代码示例来源:origin: io.rsocket.rpc/rsocket-rpc-core

  1. @Override
  2. public void onSubscribe(Subscription subscription) {
  3. if (log.isTraceEnabled()) {
  4. log.trace("On subscribe");
  5. }
  6. this.s = subscription;
  7. try (Scope scope = this.tracer.scopeManager().activate(span, false)) {
  8. scope.span().log(TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis()), "onSubscribe");
  9. if (log.isTraceEnabled()) {
  10. log.trace("On subscribe - span continued");
  11. }
  12. this.subscriber.onSubscribe(this);
  13. }
  14. }

代码示例来源:origin: org.springframework.cloud/spring-cloud-sleuth-core

  1. @Override
  2. public void cancel() {
  3. try {
  4. if (log.isTraceEnabled()) {
  5. log.trace("Cancel");
  6. }
  7. this.s.cancel();
  8. }
  9. finally {
  10. cleanup();
  11. }
  12. }

代码示例来源:origin: reactor/reactor-netty

  1. @Override
  2. final public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
  3. if (log.isTraceEnabled()) {
  4. log.trace(format(ctx.channel(), "End of the pipeline, User event {}"), evt);
  5. }
  6. if (evt instanceof NettyPipeline.SendOptionsChangeEvent) {
  7. if (log.isDebugEnabled()) {
  8. log.debug(format(ctx.channel(), "New sending options"));
  9. }
  10. ((NettyPipeline.SendOptionsChangeEvent) evt).configurator()
  11. .accept(this);
  12. return;
  13. }
  14. ctx.fireUserEventTriggered(evt);
  15. }

代码示例来源:origin: io.projectreactor.netty/reactor-netty

  1. @Override
  2. final public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
  3. if (log.isTraceEnabled()) {
  4. log.trace(format(ctx.channel(), "End of the pipeline, User event {}"), evt);
  5. }
  6. if (evt instanceof NettyPipeline.SendOptionsChangeEvent) {
  7. if (log.isDebugEnabled()) {
  8. log.debug(format(ctx.channel(), "New sending options"));
  9. }
  10. ((NettyPipeline.SendOptionsChangeEvent) evt).configurator()
  11. .accept(this);
  12. return;
  13. }
  14. ctx.fireUserEventTriggered(evt);
  15. }

代码示例来源:origin: io.rsocket.rpc/rsocket-rpc-core

  1. @Override
  2. public void cancel() {
  3. try (Scope scope = this.tracer.scopeManager().activate(span, false)) {
  4. scope.span().log(TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis()), "cancel");
  5. if (log.isTraceEnabled()) {
  6. log.trace("Cancel");
  7. }
  8. this.s.cancel();
  9. } finally {
  10. cleanup();
  11. }
  12. }

相关文章