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

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

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

Logger.isDebugEnabled介绍

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

代码示例

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

  1. /**
  2. * Reset the {@link #onHandleError(BiConsumer)} hook to the default no-op behavior.
  3. */
  4. public static void resetOnHandleError() {
  5. if (log.isDebugEnabled()) {
  6. log.debug("Reset to factory defaults: onHandleError");
  7. }
  8. onHandleErrorHook = null;
  9. }

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

  1. @Override
  2. public boolean isDebugEnabled() {
  3. return delegate.isDebugEnabled();
  4. }

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

  1. /**
  2. * Define a hook that is executed when a {@link Scheduler} has
  3. * {@link #handleError(Throwable) handled an error}. Note that it is executed after
  4. * the error has been passed to the thread uncaughtErrorHandler, which is not the
  5. * case when a fatal error occurs (see {@link Exceptions#throwIfJvmFatal(Throwable)}).
  6. *
  7. * @param c the new hook to set.
  8. */
  9. public static void onHandleError(BiConsumer<Thread, ? super Throwable> c) {
  10. if (log.isDebugEnabled()) {
  11. log.debug("Hooking new default: onHandleError");
  12. }
  13. onHandleErrorHook = Objects.requireNonNull(c, "onHandleError");
  14. }

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

  1. /**
  2. * Log an {@link IllegalStateException} that indicates more than the requested
  3. * amount was produced.
  4. *
  5. * @see Exceptions#failWithOverflow()
  6. */
  7. public static void reportMoreProduced() {
  8. if (log.isDebugEnabled()) {
  9. log.debug("More data produced than requested",
  10. Exceptions.failWithOverflow());
  11. }
  12. }

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

  1. /**
  2. * Log a {@link Exceptions#duplicateOnSubscribeException() duplicate subscription} error.
  3. *
  4. * @see Exceptions#duplicateOnSubscribeException()
  5. */
  6. public static void reportSubscriptionSet() {
  7. if (log.isDebugEnabled()) {
  8. log.debug("Duplicate Subscription has been detected",
  9. Exceptions.duplicateOnSubscribeException());
  10. }
  11. }

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

  1. /**
  2. * Log an {@link IllegalArgumentException} if the request is null or negative.
  3. *
  4. * @param n the failing demand
  5. *
  6. * @see Exceptions#nullOrNegativeRequestException(long)
  7. */
  8. public static void reportBadRequest(long n) {
  9. if (log.isDebugEnabled()) {
  10. log.debug("Negative request",
  11. Exceptions.nullOrNegativeRequestException(n));
  12. }
  13. }

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

  1. /**
  2. * An unexpected event is about to be dropped.
  3. * <p>
  4. * If no hook is registered for {@link Hooks#onNextDropped(Consumer)}, the dropped
  5. * element is just logged at DEBUG level.
  6. *
  7. * @param <T> the dropped value type
  8. * @param t the dropped data
  9. * @param context a context that might hold a local next consumer
  10. */
  11. public static <T> void onNextDropped(T t, Context context) {
  12. Objects.requireNonNull(t, "onNext");
  13. Objects.requireNonNull(context, "context");
  14. Consumer<Object> hook = context.getOrDefault(Hooks.KEY_ON_NEXT_DROPPED, null);
  15. if (hook == null) {
  16. hook = Hooks.onNextDroppedHook;
  17. }
  18. if (hook != null) {
  19. hook.accept(t);
  20. }
  21. else if (log.isDebugEnabled()) {
  22. log.debug("onNextDropped: " + t);
  23. }
  24. }

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

  1. /**
  2. * Structured logging with level adaptation and operator ascii graph if required +
  3. * protection against loggers that detect objects like {@link Fuseable.QueueSubscription}
  4. * as {@link java.util.Collection} and attempt to use their iterator for logging.
  5. *
  6. * @see #log
  7. */
  8. void safeLog(SignalType signalType, Object signalValue) {
  9. try {
  10. log(signalType, signalValue);
  11. }
  12. catch (UnsupportedOperationException uoe) {
  13. log(signalType, String.valueOf(signalValue));
  14. if (log.isDebugEnabled()) {
  15. log.debug("UnsupportedOperationException has been raised by the logging framework, does your log() placement make sense? " +
  16. "eg. 'window(2).log()' instead of 'window(2).flatMap(w -> w.log())'", uoe);
  17. }
  18. }
  19. }

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

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

代码示例来源: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 debugDismissedInNonVerboseMode() {
  3. Logger log = new Loggers.ConsoleLogger("test", new PrintStream(outContent), new PrintStream(errContent), false);
  4. log.debug("foo");
  5. log.debug("foo", new IllegalArgumentException("foo"));
  6. log.debug("foo {}", "foo");
  7. assertThat(outContent.toString()).doesNotContain("foo");
  8. assertThat(errContent.toString()).doesNotContain("foo");
  9. assertThat(log.isDebugEnabled()).as("isDebugEnabled").isFalse();
  10. }

代码示例来源: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 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 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. void evict(@Nullable T evicted) {
  2. if (evicted != null) {
  3. try {
  4. onBufferEviction.accept(evicted);
  5. }
  6. catch (Throwable ex) {
  7. if (LOGGER.isDebugEnabled()) {
  8. LOGGER.debug(
  9. "value [{}] couldn't be evicted due to a callback error. This error will be dropped: {}",
  10. evicted,
  11. ex);
  12. }
  13. Operators.onErrorDropped(ex, actual.currentContext());
  14. }
  15. Operators.onDiscard(evicted, actual.currentContext());
  16. }
  17. }

代码示例来源: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: reactor/reactor-core

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

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

  1. @Override
  2. protected void initChannel(Channel ch) {
  3. if (pipeline != null) {
  4. for (PipelineConfiguration pipelineConfiguration : pipeline) {
  5. pipelineConfiguration.consumer.accept(listener, ch);
  6. }
  7. }
  8. ChannelOperations.addReactiveBridge(ch, opsFactory, listener);
  9. if (log.isDebugEnabled()) {
  10. log.debug(format(ch, "Initialized pipeline {}"), ch.pipeline().toString());
  11. }
  12. }

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

  1. /**
  2. * Log a {@link Exceptions#duplicateOnSubscribeException() duplicate subscription} error.
  3. *
  4. * @see Exceptions#duplicateOnSubscribeException()
  5. */
  6. public static void reportSubscriptionSet() {
  7. if (log.isDebugEnabled()) {
  8. log.debug("Duplicate Subscription has been detected",
  9. Exceptions.duplicateOnSubscribeException());
  10. }
  11. }

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

  1. @Override
  2. public void channelWritabilityChanged(ChannelHandlerContext ctx) {
  3. if (log.isDebugEnabled()) {
  4. log.debug(format(ctx.channel(), "Write state change {}"),
  5. ctx.channel()
  6. .isWritable());
  7. }
  8. drain();
  9. }

相关文章