|
|
@@ -1,35 +1,44 @@
|
|
|
-import Utils.LogBuilder;
|
|
|
-import client.LogTrackingClient;
|
|
|
-import com.nju.edu.logTracking.LogConsumer;
|
|
|
-import com.nju.edu.logTracking.enums.SeecSystem;
|
|
|
+import Utils.PostHelper;
|
|
|
+import com.nju.edu.logTracking.dto.LogConfigDto;
|
|
|
+import com.nju.edu.logTracking.enums.Level;
|
|
|
+import com.nju.edu.logTracking.enums.PublishMode;
|
|
|
+import com.nju.edu.logTracking.kafka.Config;
|
|
|
|
|
|
-public class Test {
|
|
|
- public static void main(String[] args) {
|
|
|
- String data = "This is an example";
|
|
|
-
|
|
|
- //此为logBuilder,若不想使用也可自己构建log
|
|
|
- //注:此logBuilder在调用build方法时会自动添加created_time属性,值为当前时间戳
|
|
|
- String log = LogBuilder
|
|
|
- .getBuilder()
|
|
|
- .target(SeecSystem.EVAL.getName())
|
|
|
- .source(SeecSystem.CODER.getName())
|
|
|
- .operationType(1)
|
|
|
- .data(data)
|
|
|
- .message("be careful")
|
|
|
- .build();
|
|
|
+import java.io.IOException;
|
|
|
|
|
|
- //最简单使用方法,默认为medium级别
|
|
|
- LogTrackingClient
|
|
|
- .getClient()
|
|
|
- .log(log)
|
|
|
- .publish();
|
|
|
-
|
|
|
- LogConsumer myConsumer = new LogConsumer() {
|
|
|
- @Override
|
|
|
- public void run(String value) {
|
|
|
- System.out.println(value);
|
|
|
- }
|
|
|
- };
|
|
|
- myConsumer.processLog();
|
|
|
+public class Test {
|
|
|
+ public static void main(String[] args) throws IOException {
|
|
|
+// String data = "This is an example";
|
|
|
+//
|
|
|
+// //此为logBuilder,若不想使用也可自己构建log
|
|
|
+// //注:此logBuilder在调用build方法时会自动添加created_time属性,值为当前时间戳
|
|
|
+// String log = LogBuilder
|
|
|
+// .getBuilder()
|
|
|
+// .target(SeecSystem.EVAL.getName())
|
|
|
+// .source(SeecSystem.CODER.getName())
|
|
|
+// .operationType(1)
|
|
|
+// .data(data)
|
|
|
+// .message("be careful")
|
|
|
+// .build();
|
|
|
+//
|
|
|
+// //最简单使用方法,默认为medium级别
|
|
|
+// LogTrackingClient
|
|
|
+// .getClient()
|
|
|
+// .log(log)
|
|
|
+// .publish();
|
|
|
+//
|
|
|
+// LogConsumer myConsumer = new LogConsumer() {
|
|
|
+// @Override
|
|
|
+// public void run(String value) {
|
|
|
+// System.out.println(value);
|
|
|
+// }
|
|
|
+// };
|
|
|
+// //myConsumer.processLog();
|
|
|
+ LogConfigDto logConfigDto = new LogConfigDto(
|
|
|
+ Level.MEDIUM.getValue(),
|
|
|
+ PublishMode.SINGLE.getValue(),
|
|
|
+ "");
|
|
|
+ String result = PostHelper.post("http://" + Config.SERVER + "/api/publish", logConfigDto);
|
|
|
+ System.out.println(result);
|
|
|
}
|
|
|
}
|