public static void logMethodCall(Object object, String methodName, Object[] arguments) { String className = getClassName(object); String logname = "methodCalls." + className + "." + methodName; InternalLogger objLog = InternalLoggerFactory.getInstance(logname); if (!objLog.isTraceEnabled()) return; StringBuilder msg = new StringBuilder(methodName); msg.append("("); if (arguments != null) { for (int i = 0; i < arguments.length;) { msg.append(normalizedValue(arguments[i])); if (++i < arguments.length) { msg.append(","); } } } msg.append(")"); objLog.log(InternalLogLevel.TRACE, className, msg.toString(), "called from MetaClass.invokeMethod"); }
private Level fromInternal(final InternalLogLevel level) { switch (level) { case TRACE: return Level.TRACE; case DEBUG: return Level.DEBUG; case INFO: return Level.INFO; case WARN: return Level.WARN; case ERROR: return Level.ERROR; default: return null; } }
@Override public boolean isEnabled(InternalLogLevel level) { if (level == null) { return false; } switch (level) { case TRACE: return logger.isTraceEnabled(); case DEBUG: return logger.isDebugEnabled(); case INFO: return logger.isInfoEnabled(); case WARN: return logger.isWarnEnabled(); case ERROR: return logger.isErrorEnabled(); } return false; }
@Override public void log(InternalLogLevel level, String msg) { if (level == null) { return; } switch (level) { case TRACE: trace(msg); break; case DEBUG: debug(msg); break; case INFO: info(msg); break; case WARN: warn(msg); break; case ERROR: error(msg); break; } }
@Override public void log(InternalLogLevel level, String format, Object arg) { if (level == null) { return; } switch (level) { case TRACE: trace(format, arg); break; case DEBUG: debug(format, arg); break; case INFO: info(format, arg); break; case WARN: warn(format, arg); break; case ERROR: error(format, arg); break; } }
@Override public void log(InternalLogLevel level, String format, Object argA, Object argB) { if (level == null) { return; } switch (level) { case TRACE: trace(format, argA, argB); break; case DEBUG: debug(format, argA, argB); break; case INFO: info(format, argA, argB); break; case WARN: warn(format, argA, argB); break; case ERROR: error(format, argA, argB); break; } }
@Override public void log(InternalLogLevel level, String format, Object... arguments) { if (level == null) { return; } switch (level) { case TRACE: trace(format, arguments); break; case DEBUG: debug(format, arguments); break; case INFO: info(format, arguments); break; case WARN: warn(format, arguments); break; case ERROR: error(format, arguments); break; } }
@Override public void log(InternalLogLevel level, String msg, Throwable t) { if (level == null) { return; } switch (level) { case TRACE: trace(msg, t); break; case DEBUG: debug(msg, t); break; case INFO: info(msg, t); break; case WARN: warn(msg, t); break; case ERROR: error(msg, t); break; } }
public SpdyFrameLogger(InternalLogLevel level) { if (level == null) { throw new NullPointerException("level"); } logger = InternalLoggerFactory.getInstance(getClass()); this.level = level; }
/** * Creates a new instance whose logger name is the fully qualified class * name of the instance. * * @param level the log level */ public LoggingHandler(LogLevel level) { if (level == null) { throw new NullPointerException("level"); } logger = InternalLoggerFactory.getInstance(getClass()); this.level = level; internalLevel = InternalLogLevel.DEBUG; }
/** * Creates a new instance with the specified logger name. * * @param clazz the class type to generate the logger for * @param level the log level */ public LoggingHandler(Class<?> clazz, LogLevel level) { if (clazz == null) { throw new NullPointerException("clazz"); } if (level == null) { throw new NullPointerException("level"); } logger = InternalLoggerFactory.getInstance(clazz); this.level = level; internalLevel = InternalLogLevel.DEBUG; }
/** * Creates a new instance with the specified logger name. * * @param name the name of the class to use for the logger * @param level the log level */ public LoggingHandler(String name, LogLevel level) { if (name == null) { throw new NullPointerException("name"); } if (level == null) { throw new NullPointerException("level"); } logger = InternalLoggerFactory.getInstance(name); this.level = level; internalLevel = InternalLogLevel.DEBUG; }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { InternalLogLevel logLevel = InternalLogLevel.WARN; if (!stack.isEmpty()) { RedisCommand<K, V, ?> command = stack.poll(); if (debugEnabled) { logger.debug("{} Storing exception in {}", logPrefix(), command); } logLevel = InternalLogLevel.DEBUG; try { command.completeExceptionally(cause); } catch (Exception ex) { logger.warn("{} Unexpected exception during command completion exceptionally: {}", logPrefix, ex.toString(), ex); } } if (channel == null || !channel.isActive() || !isConnected()) { if (debugEnabled) { logger.debug("{} Storing exception in connectionError", logPrefix()); } logLevel = InternalLogLevel.DEBUG; connectionError = cause; } if (cause instanceof IOException && logLevel.ordinal() > InternalLogLevel.INFO.ordinal()) { logLevel = InternalLogLevel.INFO; if (SUPPRESS_IO_EXCEPTION_MESSAGES.contains(cause.getMessage())) { logLevel = InternalLogLevel.DEBUG; } } logger.log(logLevel, "{} Unexpected exception during request: {}", logPrefix, cause.toString(), cause); }
@SuppressWarnings("unchecked") @Override public void operationComplete(Future<Void> future) throws Exception { Throwable cause = future.cause(); boolean success = future.isSuccess(); dequeue(); if (!success) { if (cause instanceof EncoderException || cause instanceof Error || cause.getCause() instanceof Error) { complete(cause); return; } Channel channel = CommandHandler.this.channel; if (channel != null) { channel.eventLoop().submit(this::requeueCommands); } else { CommandHandler.this.clientResources.eventExecutorGroup().submit(this::requeueCommands); } } if (!success && !(cause instanceof ClosedChannelException)) { String message = "Unexpected exception during request: {}"; InternalLogLevel logLevel = InternalLogLevel.WARN; if (cause instanceof IOException && SUPPRESS_IO_EXCEPTION_MESSAGES.contains(cause.getMessage())) { logLevel = InternalLogLevel.DEBUG; } logger.log(logLevel, message, cause.toString(), cause); } }
public final InternalLogLevel getLogLevel() { return logLevel; }
public final void setLogLevel(InternalLogLevel logLevel) { if(logLevel!=null) { this.logLevel = logLevel; } }
@Override public boolean isEnabled(final InternalLogLevel level) { return logger.isEnabled(fromInternal(level)); }
@Override public void log(final InternalLogLevel level, final String msg) { logger.log(fromInternal(level), msg); }
@Override public void log(final InternalLogLevel level, final String format, final Object arg) { logger.log(fromInternal(level), format, arg); }
@Override public void log(final InternalLogLevel level, final String format, final Object argA, final Object argB) { logger.log(fromInternal(level), format, argA, argB); }
@Override public void log(final InternalLogLevel level, final String format, final Object... arguments) { logger.log(fromInternal(level), format, arguments); }
@Override public void log(final InternalLogLevel level, final String msg, final Throwable t) { logger.log(fromInternal(level), msg, t); }
@Override public void log(final InternalLogLevel level, final Throwable t) { logger.log(fromInternal(level), t); }
/** * Reconnect to the remote address that the closed channel was connected to. This creates a new {@link ChannelPipeline} with * the same handler instances contained in the old channel's pipeline. * * @param timeout Timer task handle. * * @throws Exception when reconnection fails. */ @Override public void run(Timeout timeout) throws Exception { reconnectSchedulerSync.set(false); reconnectScheduleTimeout = null; if (!isEventLoopGroupActive()) { logger.debug("isEventLoopGroupActive() == false"); return; } if (commandHandler != null && commandHandler.isClosed()) { logger.debug("Skip reconnect scheduling, CommandHandler is closed"); return; } if (isReconnectSuspended()) { logger.debug("Skip reconnect scheduling, reconnect is suspended"); return; } boolean shouldLog = shouldLog(); InternalLogLevel infoLevel = InternalLogLevel.INFO; InternalLogLevel warnLevel = InternalLogLevel.WARN; if (shouldLog) { lastReconnectionLogging = System.currentTimeMillis(); } else { warnLevel = InternalLogLevel.DEBUG; infoLevel = InternalLogLevel.DEBUG; } InternalLogLevel warnLevelToUse = warnLevel; try { reconnectionListener.onReconnect(new ConnectionEvents.Reconnect(attempts)); logger.log(infoLevel, "Reconnecting, last destination was {}", remoteAddress); ChannelFuture future = reconnectionHandler.reconnect(); future.addListener(it -> { if (it.isSuccess() || it.cause() == null) { return; } Throwable throwable = it.cause(); if (ReconnectionHandler.isExecutionException(throwable)) { logger.log(warnLevelToUse, "Cannot reconnect: {}", throwable.toString()); } else { logger.log(warnLevelToUse, "Cannot reconnect: {}", throwable.toString(), throwable); } if (!isReconnectSuspended()) { scheduleReconnect(); } }); } catch (Exception e) { logger.log(warnLevel, "Cannot reconnect: {}", e.toString()); } }
@Override public boolean isEnabled(InternalLogLevel level) { return delegate.isEnabled(level); }
@Override public void log(InternalLogLevel level, String msg) { if (level == InternalLogLevel.ERROR) incrementLeak(); delegate.log(level, msg); }
@Override public void log(InternalLogLevel level, String format, Object arg) { if (level == InternalLogLevel.ERROR) incrementLeak(); delegate.log(level, format, arg); }
@Override public void log(InternalLogLevel level, String format, Object argA, Object argB) { if (level == InternalLogLevel.ERROR) incrementLeak(); delegate.log(level, format, argA, argB); }
@Override public void log(InternalLogLevel level, String format, Object... arguments) { if (level == InternalLogLevel.ERROR) incrementLeak(); delegate.log(level, format, arguments); }
@Override public void log(InternalLogLevel level, String msg, Throwable t) { if (level == InternalLogLevel.ERROR) incrementLeak(); delegate.log(level, msg, t); }
@Override public boolean isEnabled(final InternalLogLevel level) { return logger.isEnabled(INTERNAL_TO_LOG4J2_LEVEL.get(level)); }
@Override public void log(final InternalLogLevel level, String msg) { logger.log(INTERNAL_TO_LOG4J2_LEVEL.get(level), msg); }
@Override public void log(final InternalLogLevel level, String format, Object arg) { logger.log(INTERNAL_TO_LOG4J2_LEVEL.get(level), format, arg); }
@Override public void log(final InternalLogLevel level, final String format, Object argA, Object argB) { logger.log(INTERNAL_TO_LOG4J2_LEVEL.get(level), format, argA, argB); }
@Override public void log(final InternalLogLevel level, final String format, Object... arguments) { logger.log(INTERNAL_TO_LOG4J2_LEVEL.get(level), format, arguments); }
@Override public void log(final InternalLogLevel level, final String msg, final Throwable t) { logger.log(INTERNAL_TO_LOG4J2_LEVEL.get(level), msg, t); }