use of io.netty.handler.logging.LogLevel in project hive by apache.
the class Rpc method createRpc.
private static Rpc createRpc(RpcConfiguration config, SaslHandler saslHandler, SocketChannel client, EventExecutorGroup egroup) throws IOException {
LogLevel logLevel = LogLevel.TRACE;
if (config.getRpcChannelLogLevel() != null) {
try {
logLevel = LogLevel.valueOf(config.getRpcChannelLogLevel());
} catch (Exception e) {
LOG.warn("Invalid log level {}, reverting to default.", config.getRpcChannelLogLevel());
}
}
boolean logEnabled = false;
switch(logLevel) {
case DEBUG:
logEnabled = LOG.isDebugEnabled();
break;
case ERROR:
logEnabled = LOG.isErrorEnabled();
break;
case INFO:
logEnabled = LOG.isInfoEnabled();
break;
case TRACE:
logEnabled = LOG.isTraceEnabled();
break;
case WARN:
logEnabled = LOG.isWarnEnabled();
break;
}
if (logEnabled) {
client.pipeline().addLast("logger", new LoggingHandler(Rpc.class, logLevel));
}
KryoMessageCodec kryo = new KryoMessageCodec(config.getMaxMessageSize(), MessageHeader.class, NullMessage.class, SaslMessage.class);
saslHandler.setKryoMessageCodec(kryo);
client.pipeline().addLast("codec", kryo).addLast("sasl", saslHandler);
return new Rpc(config, client, egroup);
}
Aggregations