craigmcc 2003/03/30 16:27:08
Modified: logging/src/java/org/apache/commons/logging/impl
Jdk14Logger.java
Log:
If we are not going to log the message anyway, do not waste the effort
to create a Throwable and figure out the calling class and method stuff.
PR: Bugzilla #18184
Submitted by: Bruno Dumon <bruno at outerthought.org>
Revision Changes Path
1.6 +21 -20
jakarta-commons/logging/src/java/org/apache/commons/logging/impl/Jdk14Logger.java
Index: Jdk14Logger.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/Jdk14Logger.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Jdk14Logger.java 30 Mar 2003 23:42:36 -0000 1.5
+++ Jdk14Logger.java 31 Mar 2003 00:27:08 -0000 1.6
@@ -110,22 +110,23 @@
// --------------------------------------------------------- Public Methods
private void log( Level level, String msg, Throwable ex ) {
- // Hack (?) to get the stack trace.
- Throwable dummyException=new Throwable();
- StackTraceElement locations[]=dummyException.getStackTrace();
- // Caller will be the third element
- String cname="unknown";
- String method="unknown";
- if( locations!=null && locations.length >2 ) {
- StackTraceElement caller=locations[2];
- cname=caller.getClassName();
- method=caller.getMethodName();
- }
-
- if( ex==null ) {
- logger.logp( level, cname, method, msg );
- } else {
- logger.logp( level, cname, method, msg, ex );
+ if (logger.isLoggable(level)) {
+ // Hack (?) to get the stack trace.
+ Throwable dummyException=new Throwable();
+ StackTraceElement locations[]=dummyException.getStackTrace();
+ // Caller will be the third element
+ String cname="unknown";
+ String method="unknown";
+ if( locations!=null && locations.length >2 ) {
+ StackTraceElement caller=locations[2];
+ cname=caller.getClassName();
+ method=caller.getMethodName();
+ }
+ if( ex==null ) {
+ logger.logp( level, cname, method, msg );
+ } else {
+ logger.logp( level, cname, method, msg, ex );
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]