io.netty.util.internal.logging.InternalLogger Java Examples

The following examples show how to use io.netty.util.internal.logging.InternalLogger. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PromiseNotificationUtil.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
/**
 * Try to cancel the {@link Promise} and log if {@code logger} is not {@code null} in case this fails.如果日志记录器不为空,则尝试取消承诺和日志,以防失败。
 */
public static void tryCancel(Promise<?> p, InternalLogger logger) {
    if (!p.cancel(false) && logger != null) {
        Throwable err = p.cause();
        if (err == null) {
            logger.warn("Failed to cancel promise because it has succeeded already: {}", p);
        } else {
            logger.warn(
                    "Failed to cancel promise because it has failed already: {}, unnotified cause:",
                    p, err);
        }
    }
}
 
Example #2
Source File: LeakDetectorTestSuite.java    From pravega with Apache License 2.0 5 votes vote down vote up
@Override
public InternalLogger newInstance(String name) {
    InternalLogger baseLogger = ((Slf4JLoggerFactory) Slf4JLoggerFactory.INSTANCE).newInstance(name);
    if (name.equals(ResourceLeakDetector.class.getName())) {
        return new ResourceLeakAssertionLogger(baseLogger);
    } else {
        return baseLogger;
    }
}
 
Example #3
Source File: ApplicationInternalLogger.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void executeVoid(@Nonnull Consumer<InternalLogger> consumer) {
  if (myDelegateLogger != null) {
    consumer.accept(myDelegateLogger);
    return;
  }

  Application application = ApplicationManager.getApplication();
  if (application != null) {
    myDelegateLogger = SLF4J_INSTANCE.newInstance(name());
    consumer.accept(myDelegateLogger);
  }
}
 
Example #4
Source File: ApplicationInternalLogger.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean executeBool(@Nonnull Function<InternalLogger, Boolean> f) {
  if (myDelegateLogger != null) {
    return f.apply(myDelegateLogger);
  }

  Application application = ApplicationManager.getApplication();
  if (application != null) {
    myDelegateLogger = SLF4J_INSTANCE.newInstance(name());
    return f.apply(myDelegateLogger);
  }

  return false;
}
 
Example #5
Source File: PromiseNotificationUtil.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
/**
 * Try to mark the {@link Promise} as failure and log if {@code logger} is not {@code null} in case this fails.尝试将承诺标记为失败,如果日志记录器在失败时不为空,则记录日志。
 */
public static void tryFailure(Promise<?> p, Throwable cause, InternalLogger logger) {
    if (!p.tryFailure(cause) && logger != null) {
        Throwable err = p.cause();
        if (err == null) {
            logger.warn("Failed to mark a promise as failure because it has succeeded already: {}", p, cause);
        } else {
            logger.warn(
                    "Failed to mark a promise as failure because it has failed already: {}, unnotified cause: {}",
                    p, ThrowableUtil.stackTraceToString(err), cause);
        }
    }
}
 
Example #6
Source File: PromiseNotificationUtil.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
/**
 * Try to mark the {@link Promise} as success and log if {@code logger} is not {@code null} in case this fails.尝试将承诺标记为成功,如果日志记录器在失败时不为空,则记录日志。
 */
public static <V> void trySuccess(Promise<? super V> p, V result, InternalLogger logger) {
    if (!p.trySuccess(result) && logger != null) {
        Throwable err = p.cause();
        if (err == null) {
            logger.warn("Failed to mark a promise as success because it has succeeded already: {}", p);
        } else {
            logger.warn(
                    "Failed to mark a promise as success because it has failed already: {}, unnotified cause:",
                    p, err);
        }
    }
}
 
Example #7
Source File: AbstractBootstrap.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
    private static void setChannelOption(
            Channel channel, ChannelOption<?> option, Object value, InternalLogger logger) {
        try {
//            设置渠道配置
            if (!channel.config().setOption((ChannelOption<Object>) option, value)) {
                logger.warn("Unknown channel option '{}' for channel '{}'", option, channel);
            }
        } catch (Throwable t) {
            logger.warn(
                    "Failed to set channel option '{}' with value '{}' for channel '{}'", option, value, channel, t);
        }
    }
 
Example #8
Source File: DelegatingChannelPromiseNotifier.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public void operationComplete(ChannelFuture future) throws Exception {
    InternalLogger internalLogger = logNotifyFailure ? logger : null;
    if (future.isSuccess()) {
        Void result = future.get();
        PromiseNotificationUtil.trySuccess(delegate, result, internalLogger);
    } else if (future.isCancelled()) {
        PromiseNotificationUtil.tryCancel(delegate, internalLogger);
    } else {
        Throwable cause = future.cause();
        PromiseNotificationUtil.tryFailure(delegate, cause, internalLogger);
    }
}
 
Example #9
Source File: Http2StreamChannelBootstrap.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private static void setChannelOption(
        Channel channel, ChannelOption<?> option, Object value, InternalLogger logger) {
    try {
        if (!channel.config().setOption((ChannelOption<Object>) option, value)) {
            logger.warn("Unknown channel option '{}' for channel '{}'", option, channel);
        }
    } catch (Throwable t) {
        logger.warn(
                "Failed to set channel option '{}' with value '{}' for channel '{}'", option, value, channel, t);
    }
}
 
Example #10
Source File: ApplicationInternalLogger.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isDebugEnabled() {
  return executeBool(InternalLogger::isDebugEnabled);
}
 
Example #11
Source File: ApplicationInternalLogger.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isInfoEnabled() {
  return executeBool(InternalLogger::isInfoEnabled);
}
 
Example #12
Source File: NetLogFactory.java    From util4j with Apache License 2.0 4 votes vote down vote up
public static InternalLogger getLogger(Class<?> c)
{
	return InternalLoggerFactory.getInstance(c);
}
 
Example #13
Source File: ApplicationInternalLogger.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isTraceEnabled() {
  return executeBool(InternalLogger::isTraceEnabled);
}
 
Example #14
Source File: ApplicationInternalLogger.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isWarnEnabled() {
  return executeBool(InternalLogger::isWarnEnabled);
}
 
Example #15
Source File: ApplicationInternalLogger.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isErrorEnabled() {
  return executeBool(InternalLogger::isErrorEnabled);
}
 
Example #16
Source File: NettyHelper.java    From dubbo-remoting-netty4 with Apache License 2.0 4 votes vote down vote up
@Override
public InternalLogger newInstance(String name) {
    return new DubboLogger(LoggerFactory.getLogger(name));
}
 
Example #17
Source File: NettyLogger.java    From light-task-scheduler with Apache License 2.0 4 votes vote down vote up
@Override
protected InternalLogger newInstance(String name) {
    return new LtsLogger(name);
}
 
Example #18
Source File: NettyHelper.java    From dubbo-remoting-netty4 with Apache License 2.0 4 votes vote down vote up
@Override
public InternalLogger newInstance(String name) {
    return new DubboLogger(LoggerFactory.getLogger(name));
}
 
Example #19
Source File: ApplicationInternalLoggerFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected InternalLogger newInstance(String name) {
  return new ApplicationInternalLogger(name);
}
 
Example #20
Source File: NettyHelper.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
@Override
public InternalLogger newInstance(String name) {
    return new DubboLogger(LoggerFactory.getLogger(name));
}
 
Example #21
Source File: NettyHelper.java    From dubbox with Apache License 2.0 4 votes vote down vote up
@Override
public InternalLogger newInstance(String name) {
    return new DubboLogger(LoggerFactory.getLogger(name));
}
 
Example #22
Source File: TraceDnsQueryLifecycleObserver.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
TraceDnsQueryLifecycleObserver(DnsQuestion question, InternalLogger logger, InternalLogLevel level) {
    this.question = checkNotNull(question, "question");
    this.logger = checkNotNull(logger, "logger");
    this.level = checkNotNull(level, "level");
}
 
Example #23
Source File: JBossNettyLoggerFactory.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
protected InternalLogger newInstance(String name) {
    return new JBossNettyInternalLogger(name);
}
 
Example #24
Source File: ModbusMasterSchedule4All.java    From easymodbus4j with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected InternalLogger getlogger() {

	return logger;
}
 
Example #25
Source File: ModbusMasterSchedule4DeviceId.java    From easymodbus4j with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected InternalLogger getlogger() {

	return logger;
}
 
Example #26
Source File: AbstractBootstrap.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
static void setChannelOptions(
        Channel channel, Map.Entry<ChannelOption<?>, Object>[] options, InternalLogger logger) {
    for (Map.Entry<ChannelOption<?>, Object> e: options) {
        setChannelOption(channel, e.getKey(), e.getValue(), logger);
    }
}
 
Example #27
Source File: AbstractBootstrap.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
static void setChannelOptions(
        Channel channel, Map<ChannelOption<?>, Object> options, InternalLogger logger) {
    for (Map.Entry<ChannelOption<?>, Object> e: options.entrySet()) {
        setChannelOption(channel, e.getKey(), e.getValue(), logger);
    }
}
 
Example #28
Source File: Http2StreamChannelBootstrap.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
private static void setChannelOptions(
        Channel channel, Map<ChannelOption<?>, Object> options, InternalLogger logger) {
    for (Map.Entry<ChannelOption<?>, Object> e: options.entrySet()) {
        setChannelOption(channel, e.getKey(), e.getValue(), logger);
    }
}
 
Example #29
Source File: Http2FrameLogger.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
private Http2FrameLogger(InternalLogLevel level, InternalLogger logger) {
    this.level = checkNotNull(level, "level");
    this.logger = checkNotNull(logger, "logger");
}
 
Example #30
Source File: TraceDnsQueryLifeCycleObserverFactory.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
TraceDnsQueryLifeCycleObserverFactory(InternalLogger logger, InternalLogLevel level) {
    this.logger = checkNotNull(logger, "logger");
    this.level = checkNotNull(level, "level");
}