提交 4450b0eb 编写于 作者: A ascrutae

修复部分问题

上级 c0f6d20a
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<groupId>log4j</groupId> <groupId>log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j</artifactId>
<version>1.2.17</version> <version>1.2.17</version>
<scope>compile</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
......
package com.a.eye.skywalking.agent; package com.a.eye.skywalking.agent;
import com.a.eye.skywalking.agent.junction.SkyWalkingEnhanceMatcher; import com.a.eye.skywalking.agent.junction.SkyWalkingEnhanceMatcher;
import com.a.eye.skywalking.client.Agent2RoutingClient;
import com.a.eye.skywalking.conf.Config; import com.a.eye.skywalking.conf.Config;
import com.a.eye.skywalking.conf.ConfigInitializer; import com.a.eye.skywalking.conf.ConfigInitializer;
import com.a.eye.skywalking.logging.EasyLogResolver; import com.a.eye.skywalking.logging.EasyLogResolver;
...@@ -37,7 +36,6 @@ public class SkyWalkingAgent { ...@@ -37,7 +36,6 @@ public class SkyWalkingAgent {
initConfig(); initConfig();
Agent2RoutingClient.INSTANCE.onReady();
final PluginDefineCategory pluginDefineCategory = PluginDefineCategory.category(new PluginBootstrap().loadPlugins()); final PluginDefineCategory pluginDefineCategory = PluginDefineCategory.category(new PluginBootstrap().loadPlugins());
new AgentBuilder.Default().type(enhanceClassMatcher(pluginDefineCategory).and(not(isInterface()))).transform(new AgentBuilder.Transformer() { new AgentBuilder.Default().type(enhanceClassMatcher(pluginDefineCategory).and(not(isInterface()))).transform(new AgentBuilder.Transformer() {
......
...@@ -10,14 +10,12 @@ import com.a.eye.skywalking.logging.api.LogManager; ...@@ -10,14 +10,12 @@ import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.network.Client; import com.a.eye.skywalking.network.Client;
import com.a.eye.skywalking.network.grpc.AckSpan; import com.a.eye.skywalking.network.grpc.AckSpan;
import com.a.eye.skywalking.network.grpc.RequestSpan; import com.a.eye.skywalking.network.grpc.RequestSpan;
import com.a.eye.skywalking.network.grpc.SendResult;
import com.a.eye.skywalking.network.grpc.client.SpanStorageClient; import com.a.eye.skywalking.network.grpc.client.SpanStorageClient;
import com.a.eye.skywalking.network.listener.client.StorageClientListener; import com.a.eye.skywalking.network.listener.client.StorageClientListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.concurrent.locks.LockSupport;
/** /**
* Created by wusheng on 2016/11/27. * Created by wusheng on 2016/11/27.
...@@ -46,6 +44,8 @@ public class Agent2RoutingClient extends Thread { ...@@ -46,6 +44,8 @@ public class Agent2RoutingClient extends Thread {
addrList.add(new ServerAddr(addrSegments[0], addrSegments[1])); addrList.add(new ServerAddr(addrSegments[0], addrSegments[1]));
} }
listener = new NetworkListener(); listener = new NetworkListener();
onReady();
} }
public void onReady() { public void onReady() {
......
...@@ -7,6 +7,8 @@ import java.net.URLEncoder; ...@@ -7,6 +7,8 @@ import java.net.URLEncoder;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import static com.a.eye.skywalking.logging.LogLevel.*;
/** /**
* Created by xin on 16-6-23. * Created by xin on 16-6-23.
*/ */
...@@ -18,14 +20,14 @@ public class EasyLogger implements com.a.eye.skywalking.logging.api.ILog { ...@@ -18,14 +20,14 @@ public class EasyLogger implements com.a.eye.skywalking.logging.api.ILog {
this.toBeLoggerClass = toBeLoggerClass; this.toBeLoggerClass = toBeLoggerClass;
} }
public void logger(String level, String message, Throwable e) { public void logger(LogLevel level, String message, Throwable e) {
Throwable dummyException = new Throwable(); Throwable dummyException = new Throwable();
StackTraceElement locations[] = dummyException.getStackTrace(); StackTraceElement locations[] = dummyException.getStackTrace();
if (locations != null && locations.length > 2) { if (locations != null && locations.length > 2) {
if(ERROR.equals(level) || WARN.equals(level)){ if (ERROR.equals(level) || WARN.equals(level)) {
WriterFactory.getLogWriter().writeError(formatMessage(level, message, locations[2])); WriterFactory.getLogWriter().writeError(formatMessage(level, message, locations[2]));
}else { } else {
WriterFactory.getLogWriter().write(formatMessage(level, message, locations[2])); WriterFactory.getLogWriter().write(formatMessage(level, message, locations[2]));
} }
} }
...@@ -53,18 +55,11 @@ public class EasyLogger implements com.a.eye.skywalking.logging.api.ILog { ...@@ -53,18 +55,11 @@ public class EasyLogger implements com.a.eye.skywalking.logging.api.ILog {
} }
private String formatMessage(String level, String message, StackTraceElement caller) { private String formatMessage(LogLevel level, String message, StackTraceElement caller) {
return level + " " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + " " return level + " " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + " "
+ caller.getClassName() + "." + caller.getMethodName() + "(" + caller.getFileName() + ":" + caller.getLineNumber() + ") " + message; + caller.getClassName() + "." + caller.getMethodName() + "(" + caller.getFileName() + ":" + caller.getLineNumber() + ") " + message;
} }
private static final String ERROR = "ERROR";
private static final String WARN = "WARN";
private static final String DEBUG = "DEBUG";
private static final String INFO = "INFO";
@Override @Override
public void info(String format) { public void info(String format) {
logger(INFO, format, null); logger(INFO, format, null);
...@@ -72,17 +67,17 @@ public class EasyLogger implements com.a.eye.skywalking.logging.api.ILog { ...@@ -72,17 +67,17 @@ public class EasyLogger implements com.a.eye.skywalking.logging.api.ILog {
@Override @Override
public void info(String format, Object... arguments) { public void info(String format, Object... arguments) {
logger(INFO, replaceParam(INFO, format, arguments), null); logger(INFO, replaceParam(format, arguments), null);
} }
@Override @Override
public void warn(String format, Object... arguments) { public void warn(String format, Object... arguments) {
logger(WARN, replaceParam(WARN, format, arguments), null); logger(WARN, replaceParam(format, arguments), null);
} }
@Override @Override
public void warn(String format, Object arguments, Throwable e) { public void warn(String format, Object arguments, Throwable e) {
logger(WARN, replaceParam(WARN, format, arguments), e); logger(WARN, replaceParam(format, arguments), e);
} }
@Override @Override
...@@ -92,7 +87,7 @@ public class EasyLogger implements com.a.eye.skywalking.logging.api.ILog { ...@@ -92,7 +87,7 @@ public class EasyLogger implements com.a.eye.skywalking.logging.api.ILog {
@Override @Override
public void error(String format, Object arguments, Throwable e) { public void error(String format, Object arguments, Throwable e) {
logger(ERROR, replaceParam(ERROR, format, arguments), e); logger(ERROR, replaceParam(format, arguments), e);
} }
@Override @Override
...@@ -122,6 +117,6 @@ public class EasyLogger implements com.a.eye.skywalking.logging.api.ILog { ...@@ -122,6 +117,6 @@ public class EasyLogger implements com.a.eye.skywalking.logging.api.ILog {
@Override @Override
public void debug(String format, Object... arguments) { public void debug(String format, Object... arguments) {
logger(DEBUG, replaceParam(DEBUG, format, arguments), null); logger(DEBUG, replaceParam(format, arguments), null);
} }
} }
package com.a.eye.skywalking.logging;
/**
* Created by xin on 2016/12/7.
*/
public enum LogLevel {
INFO, DEBUG, WARN, ERROR
}
...@@ -10,13 +10,4 @@ ...@@ -10,13 +10,4 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>skywalking-toolkit-log4j-1.x-activation</artifactId> <artifactId>skywalking-toolkit-log4j-1.x-activation</artifactId>
<dependencies>
<dependency>
<groupId>com.a.eye</groupId>
<artifactId>skywalking-toolkit-log4j-1.x</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project> </project>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册