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

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

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

Logger.isErrorEnabled介绍

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

代码示例

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

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

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

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

代码示例来源: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 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 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 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. boolean shouldLogAsDebug = level == Level.FINE && log.isDebugEnabled();
  2. boolean shouldLogAsTrace = level == Level.FINEST && log.isTraceEnabled();
  3. boolean shouldLogAsError = level != Level.FINE && level != Level.FINEST && log.isErrorEnabled();
  4. if ((options & ON_ERROR) == ON_ERROR && (shouldLogAsError || shouldLogAsDebug ||
  5. shouldLogAsTrace)) {

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

  1. public static void invokeDone(Object api, StreamContext<?> ctx) {
  2. for (Method m : api.getClass()
  3. .getMethods()) {
  4. if (m.isAnnotationPresent(IpcDone.class)) {
  5. if (m.getReturnType() == Void.TYPE) {
  6. if (m.getParameterCount() == 1 && StreamContext.class.isAssignableFrom(
  7. m.getParameterTypes()[0])) {
  8. try {
  9. m.invoke(api, ctx);
  10. }
  11. catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
  12. if (log.isErrorEnabled()) {
  13. log.error("", e);
  14. }
  15. throw new IllegalStateException(e);
  16. }
  17. return;
  18. }
  19. }
  20. throw new IllegalStateException(
  21. "IpcInit method has to be void and accepting only a single StreamContext parameter");
  22. }
  23. }
  24. }

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

  1. public static void invokeInit(Object api, StreamContext<?> ctx) {
  2. for (Method m : api.getClass()
  3. .getMethods()) {
  4. if (m.isAnnotationPresent(IpcInit.class)) {
  5. if (m.getReturnType() == Void.TYPE) {
  6. if (m.getParameterCount() == 1 && StreamContext.class.isAssignableFrom(
  7. m.getParameterTypes()[0])) {
  8. try {
  9. m.invoke(api, ctx);
  10. }
  11. catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
  12. if (log.isErrorEnabled()) {
  13. log.error("", e);
  14. }
  15. throw new IllegalStateException(e);
  16. }
  17. return;
  18. }
  19. }
  20. throw new IllegalStateException(
  21. "IpcInit method has to be void and accepting only a single StreamContext parameter");
  22. }
  23. }
  24. }

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

  1. final boolean receive(long streamId,
  2. StreamContext<?> ctx,
  3. StreamOperationsImpl io) {
  4. Publisher<?> p = producer(streamId, io);
  5. try {
  6. m.invoke(instance, ctx, p);
  7. }
  8. catch (Throwable ex) {
  9. if (log.isErrorEnabled()) {
  10. log.error("", ex);
  11. }
  12. io.sendCancel(streamId, ex.toString());
  13. }
  14. return true;
  15. }

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

  1. public static boolean dispatchServer(long streamId,
  2. Object action,
  3. StreamOperationsImpl io,
  4. StreamContext<?> ctx) {
  5. if (action instanceof IpcServerSend) {
  6. IpcServerSend rpcServerSend = (IpcServerSend) action;
  7. return rpcServerSend.send(streamId, ctx, io);
  8. }
  9. else if (action instanceof IpcServerReceive) {
  10. IpcServerReceive rpcServerReceive = (IpcServerReceive) action;
  11. return rpcServerReceive.receive(streamId, ctx, io);
  12. }
  13. else if (action instanceof IpcServerMap) {
  14. IpcServerMap rpcServerMap = (IpcServerMap) action;
  15. return rpcServerMap.map(streamId, ctx, io);
  16. }
  17. if (log.isErrorEnabled()) {
  18. log.error("",
  19. new IllegalStateException("Unsupported action: " + action.getClass()));
  20. }
  21. return false;
  22. }

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

  1. @Override
  2. public void fireContextError(Throwable err) {
  3. if (AbortedException.isConnectionReset(err)) {
  4. if (log.isDebugEnabled()) {
  5. log.debug("Connection closed remotely", err);
  6. }
  7. }
  8. else if (log.isErrorEnabled()) {
  9. log.error("Handler failure while no child channelOperation was present", err);
  10. }
  11. }

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

  1. final boolean map(long streamId, StreamContext<?> ctx, StreamOperationsImpl io) {
  2. AtomicInteger innerOnce = new AtomicInteger(2);
  3. ServerSendSubscriber sender =
  4. new ServerSendSubscriber(streamId, io, innerOnce);
  5. Publisher<?> p = producer(streamId, innerOnce, sender, io);
  6. Publisher<?> u;
  7. try {
  8. u = (Publisher<?>) m.invoke(instance, ctx, p);
  9. }
  10. catch (Throwable ex) {
  11. if (log.isErrorEnabled()) {
  12. log.error("", ex);
  13. }
  14. u = s -> Operators.error(s, ex);
  15. }
  16. if (u == null) {
  17. u = s -> Operators.error(s,
  18. new NullPointerException(
  19. "The service implementation returned a null Publisher"));
  20. }
  21. u.subscribe(sender);
  22. return true;
  23. }

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

  1. @Override
  2. protected IN decodeNext(Buffer buffer, Object context) {
  3. try {
  4. Class<IN> clazz = readType(buffer);
  5. byte[] bytes = buffer.asBytes();
  6. buffer.position(buffer.limit());
  7. return deserializer(engine, clazz).apply(bytes);
  8. } catch (RuntimeException e) {
  9. if (log.isErrorEnabled()) {
  10. log.error("Could not decode " + buffer, e);
  11. }
  12. throw e;
  13. }
  14. }

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

  1. public boolean send(long streamId, StreamContext<?> ctx, StreamOperationsImpl io) {
  2. Publisher<?> output;
  3. try {
  4. output = (Publisher<?>) m.invoke(instance, ctx);
  5. }
  6. catch (Throwable ex) {
  7. if (log.isErrorEnabled()) {
  8. log.error("", ex);
  9. }
  10. io.sendError(streamId, ex);
  11. return true;
  12. }
  13. if (output == null) {
  14. io.sendError(streamId,
  15. new IllegalStateException(
  16. "The service implementation returned a null Publisher"));
  17. return true;
  18. }
  19. ServerSendSubscriber parent = new ServerSendSubscriber(streamId, io);
  20. io.registerSubscription(streamId, parent);
  21. output.subscribe(parent);
  22. return true;
  23. }

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

  1. if (log.isErrorEnabled()) {
  2. log.error(format(channel, "Error while binding ChannelOperation on " + channel.pipeline()),
  3. t);

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

  1. boolean shouldLogAsDebug = level == Level.FINE && log.isDebugEnabled();
  2. boolean shouldLogAsTrace = level == Level.FINEST && log.isTraceEnabled();
  3. boolean shouldLogAsError = level != Level.FINE && level != Level.FINEST && log.isErrorEnabled();
  4. if ((options & ON_ERROR) == ON_ERROR && (shouldLogAsError || shouldLogAsDebug ||
  5. shouldLogAsTrace)) {

相关文章