use of com.shulie.instrument.module.log.data.pusher.log.PullLogResponse in project LinkAgent by shulieTech.
the class LogDataPusherModule method pullAgentLog.
@Command("pullAgentLog")
public CommandResponse pullAgentLog(final Map<String, String> params) {
try {
String fileName = params.get("fileName");
int batchLines = ParameterUtils.getInt(params, "batchLines", 100);
Integer lineStart = ParameterUtils.getInt(params, "lineStart", null);
PullLogResponse pullLogResponse = new PullLogResponse();
pullLogResponse.setAgentId(Pradar.AGENT_ID_NOT_CONTAIN_USER_INFO);
pullLogResponse.setAppName(AppNameUtils.appName());
pullLogResponse.setTraceId(params.get("traceId"));
pullLogResponse.setType(AGENT);
List<PullLogResponse.Log> logs = new ArrayList<PullLogResponse.Log>();
pullLogResponse.setLogs(logs);
if (null == fileName) {
// 两个日志文件都查看
// simulator.log
readLog(logs, batchLines, lineStart, simulatorConfig.getLogPath() + "/simulator.log");
// simulator-agent.log
readLog(logs, batchLines, lineStart, simulatorConfig.getLogPath() + "/simulator-agent.log");
} else {
readLog(logs, batchLines, lineStart, simulatorConfig.getLogPath() + "/" + fileName);
}
return CommandResponse.success(pullLogResponse);
} catch (Throwable e) {
logger.error("SIMULATOR: pullAgentLog occured a unknow error! ", e);
return CommandResponse.failure("pullAgentLog occured a unknow error! " + e.getMessage());
}
}
use of com.shulie.instrument.module.log.data.pusher.log.PullLogResponse in project LinkAgent by shulieTech.
the class LogDataPusherModule method pullAppLog.
@Command("pullAppLog")
public CommandResponse pullAppLog(final Map<String, String> params) {
try {
String filePath = params.get("filePath");
int batchLines = ParameterUtils.getInt(params, "batchLines", 100);
Integer lineStart = ParameterUtils.getInt(params, "lineStart", null);
PullLogResponse pullLogResponse = new PullLogResponse();
pullLogResponse.setAgentId(Pradar.AGENT_ID_NOT_CONTAIN_USER_INFO);
pullLogResponse.setAppName(AppNameUtils.appName());
pullLogResponse.setTraceId(params.get("traceId"));
pullLogResponse.setType(APP);
List<PullLogResponse.Log> logs = new ArrayList<PullLogResponse.Log>();
pullLogResponse.setLogs(logs);
File file = new File(filePath);
if (!file.exists()) {
PullLogResponse.Log log = new PullLogResponse.Log();
log.setHasLogFile(Boolean.FALSE);
log.setFileName(file.getName());
log.setFilePath(filePath);
logs.add(log);
}
readLog(logs, batchLines, lineStart, filePath);
return CommandResponse.success(pullLogResponse);
} catch (Throwable e) {
logger.error("SIMULATOR: pullAppLog occured a unknow error! ", e);
return CommandResponse.failure("pullAppLog occured a unknow error! " + e.getMessage());
}
}
Aggregations