|
@@ -1,14 +1,11 @@
|
|
|
package com.nju.edu.eval.util;
|
|
package com.nju.edu.eval.util;
|
|
|
|
|
|
|
|
-import Utils.LogBuilder;
|
|
|
|
|
-import client.LogTrackingClient;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.nju.edu.eval.data.entity.Exam;
|
|
import com.nju.edu.eval.data.entity.Exam;
|
|
|
import com.nju.edu.eval.model.vo.logdata.AnswerDTO;
|
|
import com.nju.edu.eval.model.vo.logdata.AnswerDTO;
|
|
|
import com.nju.edu.eval.model.vo.logdata.ExamLog;
|
|
import com.nju.edu.eval.model.vo.logdata.ExamLog;
|
|
|
import com.nju.edu.eval.model.vo.logdata.ExamRecordLog;
|
|
import com.nju.edu.eval.model.vo.logdata.ExamRecordLog;
|
|
|
-import com.nju.edu.logTracking.enums.SeecSystem;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
|
@@ -22,58 +19,58 @@ public class LogTracingUtil {
|
|
|
private static final Logger logger = LoggerUtil.getLogger(LogTracingUtil.class);
|
|
private static final Logger logger = LoggerUtil.getLogger(LogTracingUtil.class);
|
|
|
|
|
|
|
|
public static void logToAnalysis(String data, int type, String message) {
|
|
public static void logToAnalysis(String data, int type, String message) {
|
|
|
- // String data = "This is an example";
|
|
|
|
|
-
|
|
|
|
|
- //此为logBuilder,若不想使用也可自己构建log
|
|
|
|
|
- //注:此logBuilder在调用build方法时会自动添加created_time属性,值为当前时间戳
|
|
|
|
|
-
|
|
|
|
|
- String logData = "";
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- logData= LogBuilder
|
|
|
|
|
- .getBuilder()
|
|
|
|
|
- .target(SeecSystem.SMART) // 等待分配enum后修改
|
|
|
|
|
- .source(SeecSystem.EVAL)
|
|
|
|
|
- .operationType(type)
|
|
|
|
|
- .data(data)
|
|
|
|
|
- .message(message)
|
|
|
|
|
- .build();
|
|
|
|
|
-
|
|
|
|
|
- //最简单使用方法,默认为medium级别
|
|
|
|
|
- LogTrackingClient
|
|
|
|
|
- .getClient()
|
|
|
|
|
- .log(logData)
|
|
|
|
|
- .publish();
|
|
|
|
|
-
|
|
|
|
|
- // LoggerUtil.info(logger, logData);
|
|
|
|
|
- LoggerUtil.info(logger, "SMART --> " + logData);
|
|
|
|
|
-
|
|
|
|
|
- }catch(Exception e){
|
|
|
|
|
- LoggerUtil.info(logger, "SMART --> " + logData);
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// // String data = "This is an example";
|
|
|
|
|
+//
|
|
|
|
|
+// //此为logBuilder,若不想使用也可自己构建log
|
|
|
|
|
+// //注:此logBuilder在调用build方法时会自动添加created_time属性,值为当前时间戳
|
|
|
|
|
+//
|
|
|
|
|
+// String logData = "";
|
|
|
|
|
+//
|
|
|
|
|
+// try {
|
|
|
|
|
+// logData= LogBuilder
|
|
|
|
|
+// .getBuilder()
|
|
|
|
|
+// .target(SeecSystem.SMART) // 等待分配enum后修改
|
|
|
|
|
+// .source(SeecSystem.EVAL)
|
|
|
|
|
+// .operationType(type)
|
|
|
|
|
+// .data(data)
|
|
|
|
|
+// .message(message)
|
|
|
|
|
+// .build();
|
|
|
|
|
+//
|
|
|
|
|
+// //最简单使用方法,默认为medium级别
|
|
|
|
|
+// LogTrackingClient
|
|
|
|
|
+// .getClient()
|
|
|
|
|
+// .log(logData)
|
|
|
|
|
+// .publish();
|
|
|
|
|
+//
|
|
|
|
|
+// // LoggerUtil.info(logger, logData);
|
|
|
|
|
+// LoggerUtil.info(logger, "SMART --> " + logData);
|
|
|
|
|
+//
|
|
|
|
|
+// }catch(Exception e){
|
|
|
|
|
+// LoggerUtil.info(logger, "SMART --> " + logData);
|
|
|
|
|
+// e.printStackTrace();
|
|
|
|
|
+// }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static void logExam(Exam exam, int type) {
|
|
public static void logExam(Exam exam, int type) {
|
|
|
- try {
|
|
|
|
|
- List<AnswerDTO> answerDTOS = exam.getQuestionAndScore().entrySet().stream().
|
|
|
|
|
- map(et -> new AnswerDTO(et.getKey(), et.getValue())).collect(Collectors.toList());
|
|
|
|
|
- double totalGrade = exam.getQuestionAndScore().values().stream().collect(Collectors.summarizingInt(x -> x.intValue())).getSum();
|
|
|
|
|
-
|
|
|
|
|
- ExamLog examLog = new ExamLog(exam.getId(), totalGrade, answerDTOS, exam.getDifficulty(), new Date(), exam.getStartTime(), exam.getEndTime());
|
|
|
|
|
-
|
|
|
|
|
- logToAnalysis(JSON.toJSONStringWithDateFormat(examLog, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteDateUseDateFormat), type, "exam data");
|
|
|
|
|
- }catch (Exception e){
|
|
|
|
|
- System.out.println("构建日志数据失败");
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// try {
|
|
|
|
|
+// List<AnswerDTO> answerDTOS = exam.getQuestionAndScore().entrySet().stream().
|
|
|
|
|
+// map(et -> new AnswerDTO(et.getKey(), et.getValue())).collect(Collectors.toList());
|
|
|
|
|
+// double totalGrade = exam.getQuestionAndScore().values().stream().collect(Collectors.summarizingInt(x -> x.intValue())).getSum();
|
|
|
|
|
+//
|
|
|
|
|
+// ExamLog examLog = new ExamLog(exam.getId(), totalGrade, answerDTOS, exam.getDifficulty(), new Date(), exam.getStartTime(), exam.getEndTime());
|
|
|
|
|
+//
|
|
|
|
|
+// logToAnalysis(JSON.toJSONStringWithDateFormat(examLog, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteDateUseDateFormat), type, "exam data");
|
|
|
|
|
+// }catch (Exception e){
|
|
|
|
|
+// System.out.println("构建日志数据失败");
|
|
|
|
|
+// e.printStackTrace();
|
|
|
|
|
+// }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static void logRecord(ExamRecordLog examRecordLog) {
|
|
public static void logRecord(ExamRecordLog examRecordLog) {
|
|
|
- logToAnalysis(JSON.toJSONStringWithDateFormat(examRecordLog, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteDateUseDateFormat), 2, "record data");
|
|
|
|
|
|
|
+// logToAnalysis(JSON.toJSONStringWithDateFormat(examRecordLog, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteDateUseDateFormat), 2, "record data");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static void logSimple(String log) {
|
|
public static void logSimple(String log) {
|
|
|
- logger.info(log);
|
|
|
|
|
|
|
+// logger.info(log);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|