Example usage for io.netty.util.internal.logging InternalLogLevel DEBUG

List of usage examples for io.netty.util.internal.logging InternalLogLevel DEBUG

Introduction

In this page you can find the example usage for io.netty.util.internal.logging InternalLogLevel DEBUG.

Prototype

InternalLogLevel DEBUG

To view the source code for io.netty.util.internal.logging InternalLogLevel DEBUG.

Click Source Link

Document

'DEBUG' log level.

Usage

From source file:com.github.nettybook.ch0.LoggingHandler.java

License:Apache License

/**
 * Creates a new instance whose logger name is the fully qualified class
 * name of the instance.//from   ww  w.j av a  2 s  .c o  m
 *
 * @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;
}

From source file:com.github.nettybook.ch0.LoggingHandler.java

License:Apache License

/**
 * Creates a new instance with the specified logger name.
 *
 * @param clazz the class type to generate the logger for
 * @param level the log level/*from   w w  w .  j a v a  2s.  co  m*/
 */
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;
}

From source file:com.github.nettybook.ch0.LoggingHandler.java

License:Apache License

/**
 * 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//from   w w w  .  j  a  va2 s  .  c o m
 */
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;
}

From source file:io.lettuce.core.protocol.CommandHandler.java

License:Apache License

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {

    InternalLogLevel logLevel = InternalLogLevel.WARN;

    if (!stack.isEmpty()) {
        RedisCommand<?, ?, ?> command = stack.poll();
        if (debugEnabled) {
            logger.debug("{} Storing exception in {}", logPrefix(), command);
        }//from   w  ww .  j av a  2s.c o m
        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;
        endpoint.notifyException(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);
}

From source file:io.lettuce.core.protocol.ConnectionWatchdog.java

License:Apache License

/**
 * 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 attempt attempt counter//from  w  w w .j av a2  s  .  c om
 *
 * @throws Exception when reconnection fails.
 */
public void run(int attempt) throws Exception {

    reconnectSchedulerSync.set(false);
    reconnectScheduleTimeout = null;

    if (!isEventLoopGroupActive()) {
        logger.debug("isEventLoopGroupActive() == false");
        return;
    }

    if (!isListenOnChannelInactive()) {
        logger.debug("Skip reconnect scheduling, listener disabled");
        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.onReconnectAttempt(new ConnectionEvents.Reconnect(attempt));
        logger.log(infoLevel, "Reconnecting, last destination was {}", remoteAddress);

        CompletableFuture<Channel> future = reconnectionHandler.reconnect();

        future.whenComplete((c, t) -> {

            if (c != null && t == null) {
                return;
            }

            if (ReconnectionHandler.isExecutionException(t)) {
                logger.log(warnLevelToUse, "Cannot reconnect: {}", t.toString());
            } else {
                logger.log(warnLevelToUse, "Cannot reconnect: {}", t.toString(), t);
            }

            if (!isReconnectSuspended()) {
                scheduleReconnect();
            }
        });
    } catch (Exception e) {
        logger.log(warnLevel, "Cannot reconnect: {}", e.toString());
    }
}