Fixed issue: NETTY-30 (JDK Logging is slow.)
* Used logp instead of log
This commit is contained in:
parent
88833d9ded
commit
10bc616b4b
@ -35,33 +35,35 @@ import java.util.logging.Logger;
|
|||||||
class JdkLogger implements InternalLogger {
|
class JdkLogger implements InternalLogger {
|
||||||
|
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
|
private final String loggerName;
|
||||||
|
|
||||||
JdkLogger(Logger logger) {
|
JdkLogger(Logger logger, String loggerName) {
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
this.loggerName = loggerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void debug(String msg) {
|
public void debug(String msg) {
|
||||||
logger.log(Level.FINE, msg);
|
logger.logp(Level.FINE, loggerName, "-", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void debug(String msg, Throwable cause) {
|
public void debug(String msg, Throwable cause) {
|
||||||
logger.log(Level.FINE, msg, cause);
|
logger.logp(Level.FINE, loggerName, "-", msg, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void error(String msg) {
|
public void error(String msg) {
|
||||||
logger.log(Level.SEVERE, msg);
|
logger.logp(Level.SEVERE, loggerName, "-", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void error(String msg, Throwable cause) {
|
public void error(String msg, Throwable cause) {
|
||||||
logger.log(Level.SEVERE, msg, cause);
|
logger.logp(Level.SEVERE, loggerName, "-", msg, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void info(String msg) {
|
public void info(String msg) {
|
||||||
logger.log(Level.INFO, msg);
|
logger.logp(Level.INFO, loggerName, "-", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void info(String msg, Throwable cause) {
|
public void info(String msg, Throwable cause) {
|
||||||
logger.log(Level.INFO, msg, cause);
|
logger.logp(Level.INFO, loggerName, "-", msg, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDebugEnabled() {
|
public boolean isDebugEnabled() {
|
||||||
@ -81,15 +83,15 @@ class JdkLogger implements InternalLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void warn(String msg) {
|
public void warn(String msg) {
|
||||||
logger.log(Level.WARNING, msg);
|
logger.logp(Level.WARNING, loggerName, "-", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void warn(String msg, Throwable cause) {
|
public void warn(String msg, Throwable cause) {
|
||||||
logger.log(Level.WARNING, msg, cause);
|
logger.logp(Level.WARNING, loggerName, "-", msg, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.valueOf(logger.getName());
|
return loggerName;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -40,6 +40,6 @@ public class JdkLoggerFactory extends InternalLoggerFactory {
|
|||||||
public InternalLogger newInstance(String name) {
|
public InternalLogger newInstance(String name) {
|
||||||
final java.util.logging.Logger logger =
|
final java.util.logging.Logger logger =
|
||||||
java.util.logging.Logger.getLogger(name);
|
java.util.logging.Logger.getLogger(name);
|
||||||
return new JdkLogger(logger);
|
return new JdkLogger(logger, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class JdkLoggerTest {
|
|||||||
expect(mock.isLoggable(Level.FINE)).andReturn(true);
|
expect(mock.isLoggable(Level.FINE)).andReturn(true);
|
||||||
replay(mock);
|
replay(mock);
|
||||||
|
|
||||||
InternalLogger logger = new JdkLogger(mock);
|
InternalLogger logger = new JdkLogger(mock, "foo");
|
||||||
assertTrue(logger.isDebugEnabled());
|
assertTrue(logger.isDebugEnabled());
|
||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ public class JdkLoggerTest {
|
|||||||
expect(mock.isLoggable(Level.INFO)).andReturn(true);
|
expect(mock.isLoggable(Level.INFO)).andReturn(true);
|
||||||
replay(mock);
|
replay(mock);
|
||||||
|
|
||||||
InternalLogger logger = new JdkLogger(mock);
|
InternalLogger logger = new JdkLogger(mock, "foo");
|
||||||
assertTrue(logger.isInfoEnabled());
|
assertTrue(logger.isInfoEnabled());
|
||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ public class JdkLoggerTest {
|
|||||||
expect(mock.isLoggable(Level.WARNING)).andReturn(true);
|
expect(mock.isLoggable(Level.WARNING)).andReturn(true);
|
||||||
replay(mock);
|
replay(mock);
|
||||||
|
|
||||||
InternalLogger logger = new JdkLogger(mock);
|
InternalLogger logger = new JdkLogger(mock, "foo");
|
||||||
assertTrue(logger.isWarnEnabled());
|
assertTrue(logger.isWarnEnabled());
|
||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ public class JdkLoggerTest {
|
|||||||
expect(mock.isLoggable(Level.SEVERE)).andReturn(true);
|
expect(mock.isLoggable(Level.SEVERE)).andReturn(true);
|
||||||
replay(mock);
|
replay(mock);
|
||||||
|
|
||||||
InternalLogger logger = new JdkLogger(mock);
|
InternalLogger logger = new JdkLogger(mock, "foo");
|
||||||
assertTrue(logger.isErrorEnabled());
|
assertTrue(logger.isErrorEnabled());
|
||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
@ -99,10 +99,10 @@ public class JdkLoggerTest {
|
|||||||
java.util.logging.Logger mock =
|
java.util.logging.Logger mock =
|
||||||
createStrictMock(java.util.logging.Logger.class);
|
createStrictMock(java.util.logging.Logger.class);
|
||||||
|
|
||||||
mock.log(Level.FINE, "a");
|
mock.logp(Level.FINE, "foo", "-", "a");
|
||||||
replay(mock);
|
replay(mock);
|
||||||
|
|
||||||
InternalLogger logger = new JdkLogger(mock);
|
InternalLogger logger = new JdkLogger(mock, "foo");
|
||||||
logger.debug("a");
|
logger.debug("a");
|
||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
@ -112,10 +112,10 @@ public class JdkLoggerTest {
|
|||||||
java.util.logging.Logger mock =
|
java.util.logging.Logger mock =
|
||||||
createStrictMock(java.util.logging.Logger.class);
|
createStrictMock(java.util.logging.Logger.class);
|
||||||
|
|
||||||
mock.log(Level.FINE, "a", e);
|
mock.logp(Level.FINE, "foo", "-", "a", e);
|
||||||
replay(mock);
|
replay(mock);
|
||||||
|
|
||||||
InternalLogger logger = new JdkLogger(mock);
|
InternalLogger logger = new JdkLogger(mock, "foo");
|
||||||
logger.debug("a", e);
|
logger.debug("a", e);
|
||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
@ -125,10 +125,10 @@ public class JdkLoggerTest {
|
|||||||
java.util.logging.Logger mock =
|
java.util.logging.Logger mock =
|
||||||
createStrictMock(java.util.logging.Logger.class);
|
createStrictMock(java.util.logging.Logger.class);
|
||||||
|
|
||||||
mock.log(Level.INFO, "a");
|
mock.logp(Level.INFO, "foo", "-", "a");
|
||||||
replay(mock);
|
replay(mock);
|
||||||
|
|
||||||
InternalLogger logger = new JdkLogger(mock);
|
InternalLogger logger = new JdkLogger(mock, "foo");
|
||||||
logger.info("a");
|
logger.info("a");
|
||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
@ -138,10 +138,10 @@ public class JdkLoggerTest {
|
|||||||
java.util.logging.Logger mock =
|
java.util.logging.Logger mock =
|
||||||
createStrictMock(java.util.logging.Logger.class);
|
createStrictMock(java.util.logging.Logger.class);
|
||||||
|
|
||||||
mock.log(Level.INFO, "a", e);
|
mock.logp(Level.INFO, "foo", "-", "a", e);
|
||||||
replay(mock);
|
replay(mock);
|
||||||
|
|
||||||
InternalLogger logger = new JdkLogger(mock);
|
InternalLogger logger = new JdkLogger(mock, "foo");
|
||||||
logger.info("a", e);
|
logger.info("a", e);
|
||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
@ -151,10 +151,10 @@ public class JdkLoggerTest {
|
|||||||
java.util.logging.Logger mock =
|
java.util.logging.Logger mock =
|
||||||
createStrictMock(java.util.logging.Logger.class);
|
createStrictMock(java.util.logging.Logger.class);
|
||||||
|
|
||||||
mock.log(Level.WARNING, "a");
|
mock.logp(Level.WARNING, "foo", "-", "a");
|
||||||
replay(mock);
|
replay(mock);
|
||||||
|
|
||||||
InternalLogger logger = new JdkLogger(mock);
|
InternalLogger logger = new JdkLogger(mock, "foo");
|
||||||
logger.warn("a");
|
logger.warn("a");
|
||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
@ -164,10 +164,10 @@ public class JdkLoggerTest {
|
|||||||
java.util.logging.Logger mock =
|
java.util.logging.Logger mock =
|
||||||
createStrictMock(java.util.logging.Logger.class);
|
createStrictMock(java.util.logging.Logger.class);
|
||||||
|
|
||||||
mock.log(Level.WARNING, "a", e);
|
mock.logp(Level.WARNING, "foo", "-", "a", e);
|
||||||
replay(mock);
|
replay(mock);
|
||||||
|
|
||||||
InternalLogger logger = new JdkLogger(mock);
|
InternalLogger logger = new JdkLogger(mock, "foo");
|
||||||
logger.warn("a", e);
|
logger.warn("a", e);
|
||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
@ -177,10 +177,10 @@ public class JdkLoggerTest {
|
|||||||
java.util.logging.Logger mock =
|
java.util.logging.Logger mock =
|
||||||
createStrictMock(java.util.logging.Logger.class);
|
createStrictMock(java.util.logging.Logger.class);
|
||||||
|
|
||||||
mock.log(Level.SEVERE, "a");
|
mock.logp(Level.SEVERE, "foo", "-", "a");
|
||||||
replay(mock);
|
replay(mock);
|
||||||
|
|
||||||
InternalLogger logger = new JdkLogger(mock);
|
InternalLogger logger = new JdkLogger(mock, "foo");
|
||||||
logger.error("a");
|
logger.error("a");
|
||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
@ -190,10 +190,10 @@ public class JdkLoggerTest {
|
|||||||
java.util.logging.Logger mock =
|
java.util.logging.Logger mock =
|
||||||
createStrictMock(java.util.logging.Logger.class);
|
createStrictMock(java.util.logging.Logger.class);
|
||||||
|
|
||||||
mock.log(Level.SEVERE, "a", e);
|
mock.logp(Level.SEVERE, "foo", "-", "a", e);
|
||||||
replay(mock);
|
replay(mock);
|
||||||
|
|
||||||
InternalLogger logger = new JdkLogger(mock);
|
InternalLogger logger = new JdkLogger(mock, "foo");
|
||||||
logger.error("a", e);
|
logger.error("a", e);
|
||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user