|
@@ -76,19 +76,17 @@ function init() {
|
|
|
app.get('/isOK', (req, res) => {
|
|
|
res.send({'code': 200, 'data': true, "message": "SUCCESS"});
|
|
|
});
|
|
|
- app.get('/logs', (req, res) => {
|
|
|
+ app.get('/logs', async (req, res) => {
|
|
|
// 获取发送过来的信息(请求体的数据)
|
|
|
const param = req.query;
|
|
|
const n = param.n
|
|
|
const id = param.id
|
|
|
|
|
|
var port = -1;
|
|
|
- var isFilePath = false;
|
|
|
robot.appMap.forEach((value, key) => {
|
|
|
// logger.info(JSON.stringify(value))
|
|
|
if (value.id + "" === id + "") {
|
|
|
port = value.port
|
|
|
- isFilePath = value.isFilePath
|
|
|
}
|
|
|
})
|
|
|
|
|
@@ -97,15 +95,9 @@ function init() {
|
|
|
var logPath = "./logs" + port
|
|
|
// 将相对路径转换为绝对路径
|
|
|
const directoryPath = path.resolve(logPath);
|
|
|
- if (isFilePath === false) {
|
|
|
- if (file.checkPathSync(directoryPath)) {
|
|
|
- var app_demo = robot.getApp(id + "");
|
|
|
- app_demo.isFilePath = true
|
|
|
- }
|
|
|
- }
|
|
|
+ await file.checkPathSync(directoryPath)
|
|
|
|
|
|
logger.info(`日志相对地址:${logPath}`)
|
|
|
-
|
|
|
file.getLastFile(logPath, 10, (fileNameList) => {
|
|
|
logger.info('??1:', fileNameList);
|
|
|
result = file.readLastNLines(logPath, fileNameList, n);
|