Add log level check simply before logging. (#10080)
Motivation: In general, we will close the debug log in a product environment. However, logging without external level check may still affect performance as varargs will need to allocate an array. Modification: Add log level check simply before logging. Result: Improve performance slightly in a product environment.
This commit is contained in:
parent
65b1713ce7
commit
15fa45a84b
@ -291,7 +291,10 @@ public final class NetUtil {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.debug("Failed to get SOMAXCONN from sysctl and file {}. Default: {}", file, somaxconn, e);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Failed to get SOMAXCONN from sysctl and file {}. Default: {}",
|
||||
file, somaxconn, e);
|
||||
}
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
|
@ -137,10 +137,12 @@ public final class NativeLibraryLoader {
|
||||
return;
|
||||
} catch (Throwable ex) {
|
||||
suppressed.add(ex);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(
|
||||
"{} cannot be loaded from java.library.path, "
|
||||
+ "now trying export to -Dio.netty.native.workdir: {}", name, WORKDIR, ex);
|
||||
}
|
||||
}
|
||||
|
||||
String libname = System.mapLibraryName(name);
|
||||
String path = NATIVE_RESOURCE_HOME + libname;
|
||||
|
@ -1163,11 +1163,13 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH
|
||||
return true;
|
||||
}
|
||||
} catch (Throwable cause) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Unexpected exception while loading class {} classname {}",
|
||||
getClass(), classname, cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -71,7 +71,9 @@ public final class UnixResolverDnsServerAddressStreamProvider implements DnsServ
|
||||
return nameServerCache.mayOverrideNameServers() ? nameServerCache
|
||||
: DefaultDnsServerAddressStreamProvider.INSTANCE;
|
||||
} catch (Exception e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("failed to parse {} and/or {}", ETC_RESOLV_CONF_FILE, ETC_RESOLVER_DIR, e);
|
||||
}
|
||||
return DefaultDnsServerAddressStreamProvider.INSTANCE;
|
||||
}
|
||||
}
|
||||
@ -254,10 +256,12 @@ public final class UnixResolverDnsServerAddressStreamProvider implements DnsServ
|
||||
DnsServerAddresses existingAddresses = domainToNameServerStreamMap.put(domainName, addresses);
|
||||
if (existingAddresses != null) {
|
||||
domainToNameServerStreamMap.put(domainName, existingAddresses);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Domain name {} already maps to addresses {} so new addresses {} will be discarded",
|
||||
domainName, existingAddresses, addresses);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a file of the format <a href="https://linux.die.net/man/5/resolver">/etc/resolv.conf</a> and return the
|
||||
|
@ -173,8 +173,10 @@ final class ChannelHandlerMask {
|
||||
try {
|
||||
m = handlerType.getMethod(methodName, paramTypes);
|
||||
} catch (NoSuchMethodException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(
|
||||
"Class {} missing method {}, assume we can not skip execution", handlerType, methodName, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return m != null && m.isAnnotationPresent(Skip.class);
|
||||
|
Loading…
Reference in New Issue
Block a user