修复部分问题
This commit is contained in:
parent
c0f6d20a37
commit
4450b0eb0b
|
|
@ -16,7 +16,7 @@
|
|||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
<scope>compile</scope>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.a.eye.skywalking.agent;
|
||||
|
||||
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.ConfigInitializer;
|
||||
import com.a.eye.skywalking.logging.EasyLogResolver;
|
||||
|
|
@ -37,7 +36,6 @@ public class SkyWalkingAgent {
|
|||
|
||||
initConfig();
|
||||
|
||||
Agent2RoutingClient.INSTANCE.onReady();
|
||||
final PluginDefineCategory pluginDefineCategory = PluginDefineCategory.category(new PluginBootstrap().loadPlugins());
|
||||
|
||||
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;
|
|||
import com.a.eye.skywalking.network.Client;
|
||||
import com.a.eye.skywalking.network.grpc.AckSpan;
|
||||
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.listener.client.StorageClientListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.locks.LockSupport;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/11/27.
|
||||
|
|
@ -46,6 +44,8 @@ public class Agent2RoutingClient extends Thread {
|
|||
addrList.add(new ServerAddr(addrSegments[0], addrSegments[1]));
|
||||
}
|
||||
listener = new NetworkListener();
|
||||
|
||||
onReady();
|
||||
}
|
||||
|
||||
public void onReady() {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import java.net.URLEncoder;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import static com.a.eye.skywalking.logging.LogLevel.*;
|
||||
|
||||
/**
|
||||
* Created by xin on 16-6-23.
|
||||
*/
|
||||
|
|
@ -18,14 +20,14 @@ public class EasyLogger implements com.a.eye.skywalking.logging.api.ILog {
|
|||
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();
|
||||
StackTraceElement locations[] = dummyException.getStackTrace();
|
||||
|
||||
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]));
|
||||
}else {
|
||||
} else {
|
||||
WriterFactory.getLogWriter().write(formatMessage(level, message, locations[2]));
|
||||
}
|
||||
}
|
||||
|
|
@ -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()) + " "
|
||||
+ 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
|
||||
public void info(String format) {
|
||||
logger(INFO, format, null);
|
||||
|
|
@ -72,17 +67,17 @@ public class EasyLogger implements com.a.eye.skywalking.logging.api.ILog {
|
|||
|
||||
@Override
|
||||
public void info(String format, Object... arguments) {
|
||||
logger(INFO, replaceParam(INFO, format, arguments), null);
|
||||
logger(INFO, replaceParam(format, arguments), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String format, Object... arguments) {
|
||||
logger(WARN, replaceParam(WARN, format, arguments), null);
|
||||
logger(WARN, replaceParam(format, arguments), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String format, Object arguments, Throwable e) {
|
||||
logger(WARN, replaceParam(WARN, format, arguments), e);
|
||||
logger(WARN, replaceParam(format, arguments), e);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -92,7 +87,7 @@ public class EasyLogger implements com.a.eye.skywalking.logging.api.ILog {
|
|||
|
||||
@Override
|
||||
public void error(String format, Object arguments, Throwable e) {
|
||||
logger(ERROR, replaceParam(ERROR, format, arguments), e);
|
||||
logger(ERROR, replaceParam(format, arguments), e);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -122,6 +117,6 @@ public class EasyLogger implements com.a.eye.skywalking.logging.api.ILog {
|
|||
|
||||
@Override
|
||||
public void debug(String format, Object... arguments) {
|
||||
logger(DEBUG, replaceParam(DEBUG, format, arguments), null);
|
||||
logger(DEBUG, replaceParam(format, arguments), null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
package com.a.eye.skywalking.logging;
|
||||
|
||||
/**
|
||||
* Created by xin on 2016/12/7.
|
||||
*/
|
||||
public enum LogLevel {
|
||||
INFO, DEBUG, WARN, ERROR
|
||||
}
|
||||
|
|
@ -10,13 +10,4 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue