40 lines
1.2 KiB
Java
40 lines
1.2 KiB
Java
package com.sv.intergration;
|
|
|
|
import com.sv.netty.config.NettyConstant;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import java.io.File;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Paths;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
public class LogService {
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(LogService.class);
|
|
|
|
public Map<String, String> readLogContent() {
|
|
Map<String, String> logContent = new HashMap<>();
|
|
try {
|
|
String deviceSn = System.getProperty(NettyConstant.VENUE_CLIENT_SN);
|
|
logContent.put("deviceSn", deviceSn);
|
|
|
|
File file1 = new File("/home/venue/logs/common-default.log");
|
|
File file2 = new File("/home/venue/logs/common-error.log");
|
|
|
|
if (file1.exists()) {
|
|
logContent.put("commLog", new String(Files.readAllBytes(Paths.get(file1.getPath()))));
|
|
}
|
|
if (file2.exists()) {
|
|
logContent.put("errorLog", new String(Files.readAllBytes(Paths.get(file2.getPath()))));
|
|
}
|
|
logger.info("read log content success");
|
|
} catch (Exception e) {
|
|
logger.error("read log content fail", e);
|
|
}
|
|
return logContent;
|
|
}
|
|
|
|
}
|