Search in sources :

Example 1 with PullLogResponse

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());
    }
}
Also used : ArrayList(java.util.ArrayList) PullLogResponse(com.shulie.instrument.module.log.data.pusher.log.PullLogResponse) Command(com.shulie.instrument.simulator.api.annotation.Command)

Example 2 with PullLogResponse

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());
    }
}
Also used : ArrayList(java.util.ArrayList) File(java.io.File) PullLogResponse(com.shulie.instrument.module.log.data.pusher.log.PullLogResponse) Command(com.shulie.instrument.simulator.api.annotation.Command)

Aggregations

PullLogResponse (com.shulie.instrument.module.log.data.pusher.log.PullLogResponse)2 Command (com.shulie.instrument.simulator.api.annotation.Command)2 ArrayList (java.util.ArrayList)2 File (java.io.File)1