[강운덕] [LUCYSUS-1744] logger 변경.

git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@1434 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
Woonduk Kang
2013-04-11 11:02:31 +00:00
parent b099012038
commit 69c32caf2d
2 changed files with 37 additions and 38 deletions
@@ -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);
}
}
}
@@ -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;
}