提交 acdbc5e1 编写于 作者: wu-sheng's avatar wu-sheng

Remove all common-log modules(useless).

上级 792cf9d1
......@@ -12,7 +12,6 @@
<modules>
<module>skywalking-trace</module>
<module>skywalking-logging</module>
<module>skywalking-util</module>
</modules>
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>skywalking-commons</artifactId>
<groupId>com.a.eye</groupId>
<version>3.0-2017</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>skywalking-logging</artifactId>
<packaging>pom</packaging>
<name>skywalking-logging</name>
<url>http://maven.apache.org</url>
<modules>
<module>skywalking-logging-api</module>
<module>skywalking-logging-impl-log4j2</module>
</modules>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>skywalking-logging</artifactId>
<groupId>com.a.eye</groupId>
<version>3.0-2017</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<artifactId>skywalking-logging-api</artifactId>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>skywalking-logging</artifactId>
<groupId>com.a.eye</groupId>
<version>3.0-2017</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<artifactId>skywalking-logging-impl-log4j2</artifactId>
<dependencies>
<dependency>
<groupId>com.a.eye</groupId>
<artifactId>skywalking-logging-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6.2</version>
</dependency>
</dependencies>
</project>
package com.a.eye.skywalking.api.logging.impl.log4j2;
import com.a.eye.skywalking.api.logging.api.ILog;
import org.apache.logging.log4j.Logger;
/**
* Created by wusheng on 2016/11/11.
*/
public class Log4j2Logger implements ILog {
private Logger logger;
public Log4j2Logger(Logger logger) {
this.logger = logger;
}
@Override
public void info(String message) {
logger.info(message);
}
@Override
public void info(String message, Object... arguments) {
logger.info(message, arguments);
}
@Override
public void warn(String format, Object... arguments) {
logger.warn(format, arguments);
}
@Override
public void error(String message, Throwable e) {
logger.error(message, e);
}
@Override
public boolean isDebugEnable() {
return logger.isDebugEnabled();
}
@Override
public boolean isInfoEnable() {
return logger.isInfoEnabled();
}
@Override
public boolean isWarnEnable() {
return logger.isWarnEnabled();
}
@Override
public boolean isErrorEnable() {
return logger.isErrorEnabled();
}
@Override
public void debug(String format) {
logger.debug(format);
}
@Override
public void debug(String format, Object... arguments) {
logger.debug(format, arguments);
}
@Override
public void error(String format) {
logger.error(format);
}
}
package com.a.eye.skywalking.api.logging.impl.log4j2;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogResolver;
import org.apache.logging.log4j.LogManager;
/**
* Created by wusheng on 2016/11/11.
*/
public class Log4j2Resolver implements LogResolver {
@Override
public ILog getLogger(Class<?> clazz) {
return new Log4j2Logger(LogManager.getLogger(clazz));
}
}
package com.a.eye.skywalking.api.logging.impl.log4j2;
import org.apache.logging.log4j.Logger;
import org.junit.Test;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
/**
* Created by wusheng on 2017/2/28.
*/
public class Log4j2LoggerTest {
@Test
public void testLogProxy(){
Logger mockLogger = spy(Logger.class);
Log4j2Logger logger = new Log4j2Logger(mockLogger);
logger.isDebugEnable();
verify(mockLogger, times(1)).isDebugEnabled();
logger.isInfoEnable();
verify(mockLogger, times(1)).isInfoEnabled();
logger.isWarnEnable();
verify(mockLogger, times(1)).isWarnEnabled();
logger.isErrorEnable();
verify(mockLogger, times(1)).isErrorEnabled();
logger.debug("string");
verify(mockLogger, times(1)).debug("string");
logger.debug("string", "arg1", "args");
verify(mockLogger, times(1)).debug("string", new Object[]{"arg1", "args"});
logger.info("string");
verify(mockLogger, times(1)).info("string");
logger.info("string", "arg1", "args");
verify(mockLogger, times(1)).info("string", new Object[]{"arg1", "args"});
logger.warn("string", "arg1", "args");
verify(mockLogger, times(1)).warn("string", new Object[]{"arg1", "args"});
logger.error("string");
verify(mockLogger, times(1)).error("string");
NullPointerException exception = new NullPointerException();
logger.error("string", exception);
verify(mockLogger, times(1)).error("string", exception);
}
}
package com.a.eye.skywalking.api.logging.impl.log4j2;
import com.a.eye.skywalking.api.logging.api.ILog;
import org.junit.Assert;
import org.junit.Test;
/**
* Created by wusheng on 2017/2/28.
*/
public class Log4j2ResolverTest {
@Test
public void testGetLogger() {
Log4j2Resolver resolver = new Log4j2Resolver();
ILog logger = resolver.getLogger(Log4j2ResolverTest.class);
Assert.assertTrue(logger instanceof Log4j2Logger);
}
}
......@@ -12,11 +12,6 @@
<artifactId>skywalking-trace</artifactId>
<dependencies>
<dependency>
<groupId>com.a.eye</groupId>
<artifactId>skywalking-logging-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.a.eye</groupId>
<artifactId>skywalking-util</artifactId>
......
......@@ -4,8 +4,8 @@ import com.a.eye.skywalking.agent.junction.SkyWalkingEnhanceMatcher;
import com.a.eye.skywalking.api.conf.Config;
import com.a.eye.skywalking.api.conf.SnifferConfigInitializer;
import com.a.eye.skywalking.api.logging.EasyLogResolver;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.ILog;
import com.a.eye.skywalking.api.logging.LogManager;
import com.a.eye.skywalking.api.plugin.AbstractClassEnhancePluginDefine;
import com.a.eye.skywalking.api.plugin.PluginBootstrap;
import com.a.eye.skywalking.api.plugin.PluginFinder;
......
......@@ -20,7 +20,6 @@
</properties>
<dependencies>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
......@@ -36,11 +35,6 @@
<artifactId>disruptor</artifactId>
<version>3.3.6</version>
</dependency>
<dependency>
<groupId>com.a.eye</groupId>
<artifactId>skywalking-logging-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
......
package com.a.eye.skywalking.api.conf;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.ILog;
import com.a.eye.skywalking.api.logging.LogManager;
import com.a.eye.skywalking.api.util.ConfigInitializer;
import com.a.eye.skywalking.api.util.StringUtil;
......
package com.a.eye.skywalking.api.logging;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogResolver;
/**
* Created by wusheng on 2016/11/26.
*/
......
package com.a.eye.skywalking.api.logging;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.util.LoggingUtil;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
......@@ -76,18 +74,13 @@ public class EasyLogger implements ILog {
logger(WARN, replaceParam(format, arguments), null);
}
@Override
public void warn(String format, Object arguments, Throwable e) {
logger(WARN, replaceParam(format, arguments), e);
}
@Override
public void error(String format, Throwable e) {
logger(ERROR, format, e);
}
@Override
public void error(String format, Object arguments, Throwable e) {
public void error(Throwable e, String format, Object... arguments) {
logger(ERROR, replaceParam(format, arguments), e);
}
......
package com.a.eye.skywalking.api.logging.api;
package com.a.eye.skywalking.api.logging;
/**
* The Log interface.
......@@ -16,6 +16,8 @@ public interface ILog {
void error(String format, Throwable e);
void error(Throwable e, String format, Object... arguments);
boolean isDebugEnable();
boolean isInfoEnable();
......
package com.a.eye.skywalking.api.logging.api;
package com.a.eye.skywalking.api.logging;
/**
* {@link LogResolver} just do only one thing: return the {@link ILog} implementation.
......
package com.a.eye.skywalking.api.logging.api;
package com.a.eye.skywalking.api.logging;
/**
......@@ -8,7 +8,9 @@ package com.a.eye.skywalking.api.logging.api;
* Created by xin on 2016/11/10.
*/
public enum NoopLogger implements ILog {
INSTANCE;
INSTANCE {
};
@Override
public void info(String message) {
......@@ -64,4 +66,9 @@ public enum NoopLogger implements ILog {
public void error(String format) {
}
@Override
public void error(Throwable e, String format, Object... arguments) {
}
}
package com.a.eye.skywalking.api.plugin;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.ILog;
import com.a.eye.skywalking.api.logging.LogManager;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassEnhancePluginDefine;
import com.a.eye.skywalking.api.util.StringUtil;
import net.bytebuddy.dynamic.DynamicType;
......
package com.a.eye.skywalking.api.plugin;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.ILog;
import com.a.eye.skywalking.api.logging.LogManager;
import net.bytebuddy.pool.TypePool;
import java.net.URL;
......@@ -37,7 +37,7 @@ public class PluginBootstrap {
try {
PluginCfg.INSTANCE.load(pluginUrl.openStream());
} catch (Throwable t) {
logger.error("plugin [{}] init failure.", new Object[] {pluginUrl}, t);
logger.error(t, "plugin [{}] init failure.", pluginUrl);
}
}
......@@ -52,7 +52,7 @@ public class PluginBootstrap {
plugin.setClassTypePool(classTypePool);
plugins.add(plugin);
} catch (Throwable t) {
logger.error("loade plugin [{}] failure.", new Object[] {pluginClassName}, t);
logger.error(t, "loade plugin [{}] failure.", pluginClassName);
}
}
......
package com.a.eye.skywalking.api.plugin;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.ILog;
import com.a.eye.skywalking.api.logging.LogManager;
import java.io.IOException;
import java.net.URL;
......
package com.a.eye.skywalking.api.plugin;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.ILog;
import com.a.eye.skywalking.api.logging.LogManager;
import net.bytebuddy.ByteBuddy;
import net.bytebuddy.dynamic.ClassFileLocator;
import net.bytebuddy.dynamic.DynamicType;
......
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.ILog;
import com.a.eye.skywalking.api.logging.LogManager;
import com.a.eye.skywalking.api.plugin.interceptor.loader.InterceptorInstanceLoader;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import net.bytebuddy.implementation.bind.annotation.AllArguments;
......
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.ILog;
import com.a.eye.skywalking.api.logging.LogManager;
import com.a.eye.skywalking.api.plugin.AbstractClassEnhancePluginDefine;
import com.a.eye.skywalking.api.plugin.PluginException;
import com.a.eye.skywalking.api.plugin.interceptor.ConstructorInterceptPoint;
......
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.ILog;
import com.a.eye.skywalking.api.logging.LogManager;
import com.a.eye.skywalking.api.plugin.interceptor.loader.InterceptorInstanceLoader;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import net.bytebuddy.implementation.bind.annotation.*;
......@@ -55,7 +55,7 @@ public class ClassInstanceMethodsInterceptor {
try {
interceptor.beforeMethod(instanceContext, interceptorContext, result);
} catch (Throwable t) {
logger.error("class[{}] before method[{}] intercept failue:{}", new Object[] {obj.getClass(), method.getName(), t.getMessage()}, t);
logger.error(t,"class[{}] before method[{}] intercept failure", obj.getClass(), method.getName());
}
Object ret = null;
......@@ -69,14 +69,14 @@ public class ClassInstanceMethodsInterceptor {
try {
interceptor.handleMethodException(t, instanceContext, interceptorContext);
} catch (Throwable t2) {
logger.error("class[{}] handle method[{}] exception failue:{}", new Object[] {obj.getClass(), method.getName(), t2.getMessage()}, t2);
logger.error(t2, "class[{}] handle method[{}] exception failure", obj.getClass(), method.getName());
}
throw t;
} finally {
try {
ret = interceptor.afterMethod(instanceContext, interceptorContext, ret);
} catch (Throwable t) {
logger.error("class[{}] after method[{}] intercept failue:{}", new Object[] {obj.getClass(), method.getName(), t.getMessage()}, t);
logger.error(t, "class[{}] after method[{}] intercept failure", obj.getClass(), method.getName());
}
}
return ret;
......
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.ILog;
import com.a.eye.skywalking.api.logging.LogManager;
import com.a.eye.skywalking.api.plugin.interceptor.loader.InterceptorInstanceLoader;
import net.bytebuddy.implementation.bind.annotation.AllArguments;
import net.bytebuddy.implementation.bind.annotation.Origin;
......@@ -55,7 +55,7 @@ public class ClassStaticMethodsInterceptor {
try {
interceptor.beforeMethod(interceptorContext, result);
} catch (Throwable t) {
logger.error("class[{}] before static method[{}] intercept failue:{}", new Object[] {clazz, method.getName(), t.getMessage()}, t);
logger.error(t, "class[{}] before static method[{}] intercept failure", clazz, method.getName());
}
......@@ -70,14 +70,14 @@ public class ClassStaticMethodsInterceptor {
try {
interceptor.handleMethodException(t, interceptorContext);
} catch (Throwable t2) {
logger.error("class[{}] handle static method[{}] exception failue:{}", new Object[] {clazz, method.getName(), t2.getMessage()}, t2);
logger.error(t2, "class[{}] handle static method[{}] exception failure", clazz, method.getName(), t2.getMessage());
}
throw t;
} finally {
try {
ret = interceptor.afterMethod(interceptorContext, ret);
} catch (Throwable t) {
logger.error("class[{}] after static method[{}] intercept failue:{}", new Object[] {clazz, method.getName(), t.getMessage()}, t);
logger.error(t,"class[{}] after static method[{}] intercept failure:{}", clazz, method.getName(), t.getMessage());
}
}
return ret;
......
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.ILog;
import com.a.eye.skywalking.api.logging.LogManager;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import net.bytebuddy.implementation.bind.annotation.AllArguments;
import net.bytebuddy.implementation.bind.annotation.FieldProxy;
......
package com.a.eye.skywalking.api.plugin.interceptor.loader;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.ILog;
import com.a.eye.skywalking.api.logging.LogManager;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
......
package com.a.eye.skywalking.api.logging.api;
package com.a.eye.skywalking.api.logging;
import org.junit.After;
import org.junit.Assert;
......@@ -54,6 +54,10 @@ public class LogManagerTest {
}
@Override public void error(Throwable e, String format, Object... arguments) {
}
@Override public boolean isDebugEnable() {
return false;
}
......@@ -83,3 +87,4 @@ public class LogManagerTest {
}
}
}
package com.a.eye.skywalking.api.logging.api;
package com.a.eye.skywalking.api.logging;
import org.junit.Assert;
import org.junit.Test;
import static com.a.eye.skywalking.api.logging.api.NoopLogger.INSTANCE;
import static com.a.eye.skywalking.api.logging.NoopLogger.INSTANCE;
/**
* Created by wusheng on 2017/2/27.
......
......@@ -2,8 +2,8 @@ package com.a.eye.skywalking.toolkit.activation.trace;
import com.a.eye.skywalking.api.context.ContextCarrier;
import com.a.eye.skywalking.api.context.ContextManager;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.ILog;
import com.a.eye.skywalking.api.logging.LogManager;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.StaticMethodInvokeContext;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册