优化 日志读取

pull/199/head
midoks 3 years ago
parent 5583db0c70
commit 2c0231155d
  1. 2
      class/core/files_api.py
  2. 4
      class/core/site_api.py
  3. 2
      plugins/mariadb/index.py
  4. 2
      plugins/mysql/index.py
  5. 4
      plugins/supervisor/index.py

@ -36,7 +36,7 @@ class files_api:
return mw.returnJson(False, '文件不存在', (path,))
try:
data = mw.getNumLines(path, int(line))
data = mw.getLastLine(path, int(line))
return mw.returnJson(True, 'OK', data)
except Exception as ex:
return mw.returnJson(False, u'无法正确读取文件!' + str(ex))

@ -1829,13 +1829,13 @@ location ^~ {from} {
logPath = mw.getLogsDir() + '/' + siteName + '.log'
if not os.path.exists(logPath):
return mw.returnJson(False, '日志为空')
return mw.returnJson(True, mw.getNumLines(logPath, 100))
return mw.returnJson(True, mw.getLastLine(logPath, 100))
def getErrorLogs(self, siteName):
logPath = mw.getLogsDir() + '/' + siteName + '.error.log'
if not os.path.exists(logPath):
return mw.returnJson(False, '日志为空')
return mw.returnJson(True, mw.getNumLines(logPath, 100))
return mw.returnJson(True, mw.getLastLine(logPath, 100))
# 取日志状态
def getLogsStatus(self, siteName):

@ -304,7 +304,7 @@ def getErrorLog():
if 'close' in args:
mw.writeFile(filename, '')
return mw.returnJson(False, '日志已清空')
info = mw.getNumLines(filename, 18)
info = mw.getLastLine(filename, 18)
return mw.returnJson(True, 'OK', info)

@ -333,7 +333,7 @@ def getErrorLog():
if 'close' in args:
mw.writeFile(filename, '')
return mw.returnJson(False, '日志已清空')
info = mw.getNumLines(filename, 18)
info = mw.getLastLine(filename, 18)
return mw.returnJson(True, 'OK', info)

@ -472,7 +472,7 @@ def readConfigLogTpl():
stdout_logfile = line.strip().split('=')[1]
if stdout_logfile != '':
data = mw.getNumLines(stdout_logfile, int(line_log))
data = mw.getLastLine(stdout_logfile, int(line_log))
return mw.returnJson(True, 'OK', data)
return mw.returnJson(False, 'OK', '')
@ -494,7 +494,7 @@ def readConfigLogErrorTpl():
stderr_logfile = line.strip().split('=')[1]
if stderr_logfile != '':
data = mw.getNumLines(stderr_logfile, int(line_log))
data = mw.getLastLine(stderr_logfile, int(line_log))
return mw.returnJson(True, 'OK', data)
return mw.returnJson(False, 'OK', '')

Loading…
Cancel
Save