From 68dbe5a5dec37c8ca0c0932d9984378dc3c998e2 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Fri, 11 Jan 2019 19:00:16 +0800 Subject: [PATCH] update --- class/core/public.py | 1 - plugins/mysql/index.py | 21 ++++++++++++++++++++- plugins/mysql/js/mysql.js | 24 +++++++++++++++++++++++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/class/core/public.py b/class/core/public.py index 8e378511e..8854da29c 100755 --- a/class/core/public.py +++ b/class/core/public.py @@ -435,7 +435,6 @@ def getNumLines(path, num, p=1): break fp.close() except Exception as e: - print str(e) return '' return "\n".join(data) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 4e556fb32..f277d5eaa 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -182,10 +182,27 @@ def binLog(): os.system('rm -f ' + path + '/mysql-bin.*') public.writeFile(conf, con) - return public.returnJson(True, '设置成功!') +def getErrorLog(): + args = getArgs() + path = getDataDir() + filename = '' + for n in os.listdir(path): + if len(n) < 5: + continue + if n == 'error.log': + filename = path + '/' + n + break + if not os.path.exists(filename): + return public.returnJson(False, '指定文件不存在!') + if args.has_key('close'): + public.writeFile(filename, '') + return public.returnJson(True, '日志已清空') + return public.getNumLines(filename, 1000) + + def getShowLogFile(): file = getConf() content = public.readFile(file) @@ -811,6 +828,8 @@ if __name__ == "__main__": print getConf() elif func == 'bin_log': print binLog() + elif func == 'error_log': + print getErrorLog() elif func == 'show_log': print getShowLogFile() elif func == 'my_port': diff --git a/plugins/mysql/js/mysql.js b/plugins/mysql/js/mysql.js index 8dac1f994..23e746f97 100755 --- a/plugins/mysql/js/mysql.js +++ b/plugins/mysql/js/mysql.js @@ -969,8 +969,30 @@ function myLogs(){ setTimeout(function(){ myLogs(); - }, 3000); + }, 2000); }); }); + + //清空日志 + $(".btn-clear").click(function () { + myPost('error_log', 'close=1', function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); + + setTimeout(function(){ + myLogs(); + }, 2000); + }); + }) + + myPost('error_log', 'p=1', function(data){ + var error_body = data.data; + if (error_body == "") { + error_body = '当前没有日志内容!'; + } + $("#error_log").text(error_body); + var ob = document.getElementById('error_log'); + ob.scrollTop = ob.scrollHeight; + }); }); }