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

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

Introduction

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

Prototype

InternalLogLevel INFO

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

Click Source Link

Document

'INFO' log level.

Usage

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  a  va 2s  .  co  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 ww  .  j  a va 2 s. co m
 *
 * @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());
    }
}