From 69c32caf2d35cac13eb6155c8c20b06be3eaea73 Mon Sep 17 00:00:00 2001 From: Woonduk Kang Date: Thu, 11 Apr 2013 11:02:31 +0000 Subject: [PATCH] =?UTF-8?q?[=EA=B0=95=EC=9A=B4=EB=8D=95]=20[LUCYSUS-1744]?= =?UTF-8?q?=20logger=20=EB=B3=80=EA=B2=BD.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@1434 84d0f5b1-2673-498c-a247-62c4ff18d310 --- .../bci/JavaAssistByteCodeInstrumentor.java | 24 ++++----- .../interceptor/bci/JavaAssistClass.java | 51 +++++++++---------- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/profiler/interceptor/bci/JavaAssistByteCodeInstrumentor.java b/src/main/java/com/profiler/interceptor/bci/JavaAssistByteCodeInstrumentor.java index b75523af3..6bc20b76d 100644 --- a/src/main/java/com/profiler/interceptor/bci/JavaAssistByteCodeInstrumentor.java +++ b/src/main/java/com/profiler/interceptor/bci/JavaAssistByteCodeInstrumentor.java @@ -5,12 +5,12 @@ import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.net.URLClassLoader; import java.security.ProtectionDomain; -import java.util.logging.Level; -import java.util.logging.Logger; + import com.profiler.Agent; -import com.profiler.DefaultAgent; import com.profiler.interceptor.Interceptor; +import com.profiler.logging.Logger; +import com.profiler.logging.LoggerFactory; import javassist.CannotCompileException; import javassist.ClassPool; import javassist.CtClass; @@ -18,7 +18,7 @@ import javassist.NotFoundException; public class JavaAssistByteCodeInstrumentor implements ByteCodeInstrumentor { - private final Logger logger = Logger.getLogger(this.getClass().getName()); + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); private ClassPool classPool; @@ -60,8 +60,8 @@ public class JavaAssistByteCodeInstrumentor implements ByteCodeInstrumentor { try { classPool.appendClassPath(pathName); } catch (NotFoundException e) { - if (logger.isLoggable(Level.WARNING)) { - logger.log(Level.WARNING, "appendClassPath fail. lib not found. " + e.getMessage(), e); + if (logger.isWarnEnabled()) { + logger.warn("appendClassPath fail. lib not found. " + e.getMessage(), e); } } } @@ -87,8 +87,8 @@ public class JavaAssistByteCodeInstrumentor implements ByteCodeInstrumentor { @Override public Class defineClass(ClassLoader classLoader, String defineClass, ProtectionDomain protectedDomain) throws InstrumentException { - if (logger.isLoggable(Level.INFO)) { - logger.info("defineClass class:" + defineClass + " cl:" + classLoader); + if (logger.isInfoEnabled()) { + logger.warn("defineClass class:" + defineClass + " cl:" + classLoader); } try { // 아래 classLoaderChecker가 생겼으니 classLoader 를 같이 락으로 잡아야 되지 않는가? @@ -117,7 +117,7 @@ public class JavaAssistByteCodeInstrumentor implements ByteCodeInstrumentor { for (CtClass nested : nestedClasses) { // 재귀하면서 최하위부터 로드 defineNestedClass(nested, classLoader, protectedDomain); - if (logger.isLoggable(Level.INFO)) { + if (logger.isInfoEnabled()) { logger.info("defineNestedClass class:" + nested.getName() + " cl:" + classLoader); } nested.toClass(classLoader, protectedDomain); @@ -189,12 +189,12 @@ public class JavaAssistByteCodeInstrumentor implements ByteCodeInstrumentor { try { classPool.appendClassPath(filePath); // 만약 한개만 로딩해도 된다면. return true 할것 - if (logger.isLoggable(Level.INFO)) { + if (logger.isInfoEnabled()) { logger.info("Loaded " + filePath + " library."); } } catch (NotFoundException e) { - if (logger.isLoggable(Level.WARNING)) { - logger.log(Level.WARNING, "lib load fail. path:" + filePath + " cl:" + classLoader + " Cause:" + e.getMessage(), e); + if (logger.isWarnEnabled()) { + logger.warn("lib load fail. path:" + filePath + " cl:" + classLoader + " Cause:" + e.getMessage(), e); } } } diff --git a/src/main/java/com/profiler/interceptor/bci/JavaAssistClass.java b/src/main/java/com/profiler/interceptor/bci/JavaAssistClass.java index 8e26e4cc6..51c097622 100644 --- a/src/main/java/com/profiler/interceptor/bci/JavaAssistClass.java +++ b/src/main/java/com/profiler/interceptor/bci/JavaAssistClass.java @@ -1,18 +1,17 @@ package com.profiler.interceptor.bci; import java.io.IOException; -import java.util.logging.Level; -import java.util.logging.Logger; import com.profiler.common.mapping.ApiMappingTable; import com.profiler.common.mapping.ApiUtils; import com.profiler.interceptor.*; +import com.profiler.logging.LoggerFactory; import com.profiler.util.JavaAssistUtils; import javassist.*; public class JavaAssistClass implements InstrumentClass { - private final Logger logger = Logger.getLogger(this.getClass().getName()); + private final com.profiler.logging.Logger logger = LoggerFactory.getLogger(this.getClass().getName()); private JavaAssistByteCodeInstrumentor instrumentor; private CtClass ctClass; @@ -30,8 +29,8 @@ public class JavaAssistClass implements InstrumentClass { constructor.insertBefore(code); return true; } catch (Exception e) { - if (logger.isLoggable(Level.WARNING)) { - logger.log(Level.WARNING, e.getMessage(), e); + if (logger.isWarnEnabled()) { + logger.warn(e.getMessage(), e); } return false; } @@ -44,8 +43,8 @@ public class JavaAssistClass implements InstrumentClass { constructor.insertAfter(code); return true; } catch (Exception e) { - if (logger.isLoggable(Level.WARNING)) { - logger.log(Level.WARNING, e.getMessage(), e); + if (logger.isWarnEnabled()) { + logger.warn(e.getMessage(), e); } return false; } @@ -58,8 +57,8 @@ public class JavaAssistClass implements InstrumentClass { method.insertBefore(code); return true; } catch (Exception e) { - if (logger.isLoggable(Level.WARNING)) { - logger.log(Level.WARNING, e.getMessage(), e); + if (logger.isWarnEnabled()) { + logger.warn(e.getMessage(), e); } return false; } @@ -72,8 +71,8 @@ public class JavaAssistClass implements InstrumentClass { method.insertAfter(code); return true; } catch (Exception e) { - if (logger.isLoggable(Level.WARNING)) { - logger.log(Level.WARNING, e.getMessage(), e); + if (logger.isWarnEnabled()) { + logger.warn(e.getMessage(), e); } return false; } @@ -274,7 +273,7 @@ public class JavaAssistClass implements InstrumentClass { after.end(); } String buildAfter = after.toString(); - if (logger.isLoggable(Level.INFO)) { + if (logger.isInfoEnabled()) { logger.info("addStaticAfterInterceptor after behavior:" + behavior.getLongName() + " code:" + buildAfter); } behavior.insertAfter(buildAfter); @@ -299,7 +298,7 @@ public class JavaAssistClass implements InstrumentClass { catchCode.end(); } String buildCatch = catchCode.toString(); - if (logger.isLoggable(Level.INFO)) { + if (logger.isInfoEnabled()) { logger.info("addStaticAfterInterceptor catch behavior:" + behavior.getLongName() + " code:" + buildCatch); } CtClass th = instrumentor.getClassPool().get("java.lang.Throwable"); @@ -370,7 +369,7 @@ public class JavaAssistClass implements InstrumentClass { code.end(); } String buildBefore = code.toString(); - if (logger.isLoggable(Level.INFO)) { + if (logger.isInfoEnabled()) { logger.info("addStaticBeforeInterceptor catch behavior:" + behavior.getLongName() + " code:" + buildBefore); } @@ -399,8 +398,8 @@ public class JavaAssistClass implements InstrumentClass { for (CtMethod method : methods) { if (method.isEmpty()) { - if (logger.isLoggable(Level.FINE)) { - logger.fine(method.getLongName() + " is empty."); + if (logger.isDebugEnabled()) { + logger.debug("{} is empty.", method.getLongName()); } continue; } @@ -412,8 +411,8 @@ public class JavaAssistClass implements InstrumentClass { } return true; } catch (Exception e) { - if (logger.isLoggable(Level.WARNING)) { - logger.log(Level.WARNING, e.getMessage(), e); + if (logger.isWarnEnabled()) { + logger.warn(e.getMessage(), e); } } return false; @@ -435,8 +434,8 @@ public class JavaAssistClass implements InstrumentClass { for (CtConstructor constructor : constructors) { if (constructor.isEmpty()) { - if (logger.isLoggable(Level.FINE)) { - logger.fine(constructor.getLongName() + " is empty."); + if (logger.isDebugEnabled()) { + logger.debug(constructor.getLongName() + " is empty."); } continue; } @@ -454,8 +453,8 @@ public class JavaAssistClass implements InstrumentClass { } return true; } catch (Exception e) { - if (logger.isLoggable(Level.WARNING)) { - logger.log(Level.WARNING, e.getMessage(), e); + if (logger.isWarnEnabled()) { + logger.warn(e.getMessage(), e); } } return false; @@ -470,8 +469,8 @@ public class JavaAssistClass implements InstrumentClass { } } String paramsStr = sb.toString(); - if (logger.isLoggable(Level.FINE)) { - logger.fine("params type:" + paramsStr); + if (logger.isDebugEnabled()) { + logger.debug("params type:{}"); } return paramsStr; } @@ -495,9 +494,9 @@ public class JavaAssistClass implements InstrumentClass { ctClass.detach(); return bytes; } catch (IOException e) { - logger.log(Level.INFO, "IoException class:" + ctClass.getName() + " " + e.getMessage(), e); + logger.info("IoException class:" + ctClass.getName() + " " + e.getMessage(), e); } catch (CannotCompileException e) { - logger.log(Level.INFO, "CannotCompileException class:" + ctClass.getName() + " " + e.getMessage(), e); + logger.info("CannotCompileException class:" + ctClass.getName() + " " + e.getMessage(), e); } return null; }