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

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

本文整理了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

@Override
public void onSubscribe(Subscription subscription) {
  if (log.isTraceEnabled()) {
    log.trace("On subscribe");
  }
  this.s = subscription;
  try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(this.span)) {
    if (log.isTraceEnabled()) {
      log.trace("On subscribe - span continued");
    }
    this.subscriber.onSubscribe(this);
  }
}

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

@Override
public void request(long n) {
  if (log.isTraceEnabled()) {
    log.trace("Request");
  }
  try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(this.span)) {
    if (log.isTraceEnabled()) {
      log.trace("Request - continued");
    }
    this.s.request(n);
    // no additional cleaning is required cause we operate on scopes
    if (log.isTraceEnabled()) {
      log.trace("Request after cleaning. Current span [{}]",
          this.tracer.currentSpan());
    }
  }
}

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

void cleanup() {
  if (compareAndSet(false, true)) {
    if (log.isTraceEnabled()) {
      log.trace("Cleaning up");
    }
    this.span.finish();
    if (log.isTraceEnabled()) {
      log.trace("Span closed");
    }
    if (this.rootSpan != null) {
      this.rootSpan.finish();
      if (log.isTraceEnabled()) {
        log.trace("Closed root span");
      }
    }
  }
}

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

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

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

@Override
public void cancel() {
  try {
    if (log.isTraceEnabled()) {
      log.trace("Cancel");
    }
    this.s.cancel();
  }
  finally {
    cleanup();
  }
}

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

@Test
public void logErrorUsesDebugWhenFine() {
  Level level = Level.FINE;
  Mono<String> source = Mono.error(new IllegalStateException("ignored"));
  Logger mockLogger = Mockito.mock(Logger.class);
  when(mockLogger.isErrorEnabled()).thenReturn(true);
  when(mockLogger.isDebugEnabled()).thenReturn(true);
  when(mockLogger.isTraceEnabled()).thenReturn(true);
  SignalLogger<String> sl = new SignalLogger<>(source, null, level,
      false, s -> mockLogger);
  sl.onErrorCall().accept(new IllegalStateException("boom"));
  verify(mockLogger, never()).isErrorEnabled();
  verify(mockLogger, times(1)).isDebugEnabled();
  verify(mockLogger, never()).isTraceEnabled();
  verify(mockLogger, times(1)).debug(Mockito.anyString(), (Object[]) Mockito.any());
  verify(mockLogger, times(1)).debug(Mockito.anyString(), (Throwable) Mockito.any());
  verifyNoMoreInteractions(mockLogger);
}

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

@Test
public void logErrorUsesErrorWhenInfo() {
  Level level = Level.INFO;
  Mono<String> source = Mono.error(new IllegalStateException("ignored"));
  Logger mockLogger = Mockito.mock(Logger.class);
  when(mockLogger.isErrorEnabled()).thenReturn(true);
  when(mockLogger.isDebugEnabled()).thenReturn(true);
  when(mockLogger.isTraceEnabled()).thenReturn(true);
  SignalLogger<String> sl = new SignalLogger<>(source, null, level,
      false, s -> mockLogger);
  sl.onErrorCall().accept(new IllegalStateException("boom"));
  verify(mockLogger, times(1)).isErrorEnabled();
  verify(mockLogger, never()).isDebugEnabled();
  verify(mockLogger, never()).isTraceEnabled();
  verify(mockLogger, times(1)).error(Mockito.anyString(), (Object[]) Mockito.any());
  verify(mockLogger, times(1)).error(Mockito.anyString(), (Throwable) Mockito.any());
  verifyNoMoreInteractions(mockLogger);
}

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

@Test
public void logErrorUsesErrorWhenWarning() {
  Level level = Level.WARNING;
  Mono<String> source = Mono.error(new IllegalStateException("ignored"));
  Logger mockLogger = Mockito.mock(Logger.class);
  when(mockLogger.isErrorEnabled()).thenReturn(true);
  when(mockLogger.isDebugEnabled()).thenReturn(true);
  when(mockLogger.isTraceEnabled()).thenReturn(true);
  SignalLogger<String> sl = new SignalLogger<>(source, null, level,
      false, s -> mockLogger);
  sl.onErrorCall().accept(new IllegalStateException("boom"));
  verify(mockLogger, times(1)).isErrorEnabled();
  verify(mockLogger, never()).isDebugEnabled();
  verify(mockLogger, never()).isTraceEnabled();
  verify(mockLogger, times(1)).error(Mockito.anyString(), (Object[]) Mockito.any());
  verify(mockLogger, times(1)).error(Mockito.anyString(), (Throwable) Mockito.any());
  verifyNoMoreInteractions(mockLogger);
}

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

@Test
public void logErrorUsesErrorWhenSevere() {
  Level level = Level.SEVERE;
  Mono<String> source = Mono.error(new IllegalStateException("ignored"));
  Logger mockLogger = Mockito.mock(Logger.class);
  when(mockLogger.isErrorEnabled()).thenReturn(true);
  when(mockLogger.isDebugEnabled()).thenReturn(true);
  when(mockLogger.isTraceEnabled()).thenReturn(true);
  SignalLogger<String> sl = new SignalLogger<>(source, null, level,
      false, s -> mockLogger);
  sl.onErrorCall().accept(new IllegalStateException("boom"));
  verify(mockLogger, times(1)).isErrorEnabled();
  verify(mockLogger, never()).isDebugEnabled();
  verify(mockLogger, never()).isTraceEnabled();
  verify(mockLogger, times(1)).error(Mockito.anyString(), (Object[]) Mockito.any());
  verify(mockLogger, times(1)).error(Mockito.anyString(), (Throwable) Mockito.any());
  verifyNoMoreInteractions(mockLogger);
}

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

@Test
public void traceDismissedInNonVerboseMode() {
  Logger log = new Loggers.ConsoleLogger("test", new PrintStream(outContent), new PrintStream(errContent), false);
  log.trace("foo");
  log.trace("foo", new IllegalArgumentException("foo"));
  log.trace("foo {}", "foo");
  assertThat(outContent.toString()).doesNotContain("foo");
  assertThat(errContent.toString()).doesNotContain("foo");
  assertThat(log.isTraceEnabled()).as("isTraceEnabled").isFalse();
}

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

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

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

SpanSubscriber(Subscriber<? super T> subscriber, Context ctx, Tracing tracing,
    String name) {
  this.subscriber = subscriber;
  this.tracer = tracing.tracer();
  Span root = ctx.getOrDefault(Span.class, this.tracer.currentSpan());
  if (log.isTraceEnabled()) {
    log.trace("Span from context [{}]", root);
  }
  this.rootSpan = root;
  if (log.isTraceEnabled()) {
    log.trace("Stored context root span [{}]", this.rootSpan);
  }
  this.span = root != null ? this.tracer
      .nextSpan(TraceContextOrSamplingFlags.create(root.context())).name(name)
      : this.tracer.nextSpan().name(name);
  if (log.isTraceEnabled()) {
    log.trace("Created span [{}], with name [{}]", this.span, name);
  }
  this.context = ctx.put(Span.class, this.span);
}

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

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

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

@Override
public void request(long n) {
 if (log.isTraceEnabled()) {
  log.trace("Request");
 }
 if (log.isTraceEnabled()) {
  log.trace("Request - continued");
 }
 this.s.request(n);
 // no additional cleaning is required cause we operate on scopes
 if (log.isTraceEnabled()) {
  log.trace("Request after cleaning. Current span [{}]", this.tracer.activeSpan());
 }
}

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

@Override
public void onSubscribe(Subscription subscription) {
  if (log.isTraceEnabled()) {
    log.trace("On subscribe");
  }
  this.s = subscription;
  try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(this.span)) {
    if (log.isTraceEnabled()) {
      log.trace("On subscribe - span continued");
    }
    this.subscriber.onSubscribe(this);
  }
}

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

@Override
public void onSubscribe(Subscription subscription) {
 if (log.isTraceEnabled()) {
  log.trace("On subscribe");
 }
 this.s = subscription;
 try (Scope scope = this.tracer.scopeManager().activate(span, false)) {
  scope.span().log(TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis()), "onSubscribe");
  if (log.isTraceEnabled()) {
   log.trace("On subscribe - span continued");
  }
  this.subscriber.onSubscribe(this);
 }
}

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

@Override
public void cancel() {
  try {
    if (log.isTraceEnabled()) {
      log.trace("Cancel");
    }
    this.s.cancel();
  }
  finally {
    cleanup();
  }
}

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

@Override
final public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
  if (log.isTraceEnabled()) {
    log.trace(format(ctx.channel(), "End of the pipeline, User event {}"), evt);
  }
  if (evt instanceof NettyPipeline.SendOptionsChangeEvent) {
    if (log.isDebugEnabled()) {
      log.debug(format(ctx.channel(), "New sending options"));
    }
    ((NettyPipeline.SendOptionsChangeEvent) evt).configurator()
                          .accept(this);
    return;
  }
  ctx.fireUserEventTriggered(evt);
}

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

@Override
final public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
  if (log.isTraceEnabled()) {
    log.trace(format(ctx.channel(), "End of the pipeline, User event {}"), evt);
  }
  if (evt instanceof NettyPipeline.SendOptionsChangeEvent) {
    if (log.isDebugEnabled()) {
      log.debug(format(ctx.channel(), "New sending options"));
    }
    ((NettyPipeline.SendOptionsChangeEvent) evt).configurator()
                          .accept(this);
    return;
  }
  ctx.fireUserEventTriggered(evt);
}

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

@Override
public void cancel() {
 try (Scope scope = this.tracer.scopeManager().activate(span, false)) {
  scope.span().log(TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis()), "cancel");
  if (log.isTraceEnabled()) {
   log.trace("Cancel");
  }
  this.s.cancel();
 } finally {
  cleanup();
 }
}

相关文章