|
@@ -112,9 +112,15 @@ function getLastFile(dirPath, number, callback) {
|
|
|
// 读取日志(倒叙)指定行数
|
|
|
function readLastNLines(dirPath, filePathList, n) {
|
|
|
const fileList = filePathList.map((item) => {
|
|
|
- logger.info("日志文件:" + dirPath + "/" + item)
|
|
|
- const content = fs.readFileSync(`${dirPath}/${item}`, "utf8");
|
|
|
- const lines = content.trim().split("\n");
|
|
|
+ var path = dirPath + "/" + item
|
|
|
+ // 将相对路径转换为绝对路径
|
|
|
+ const directoryPath = path.resolve(path);
|
|
|
+ logger.info("日志文件:" + directoryPath)
|
|
|
+ let lines = [""]
|
|
|
+ if (checkFilePath(directoryPath)) {
|
|
|
+ const content = fs.readFileSync(`${directoryPath}`, "utf8");
|
|
|
+ lines = content.trim().split("\n");
|
|
|
+ }
|
|
|
return {
|
|
|
filePath: item,
|
|
|
lines: lines,
|