From c0cf9ae2835f9a19fe6a9af743ddd24be7c3a123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 5 Apr 2022 23:03:16 +0800 Subject: #1018 cleanup logs --- script/proto/proto.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'script/proto') diff --git a/script/proto/proto.lua b/script/proto/proto.lua index 83a188f9..cb549764 100644 --- a/script/proto/proto.lua +++ b/script/proto/proto.lua @@ -12,14 +12,14 @@ local function logSend(buf) if not RPCLOG then return end - log.debug('rpc send:', buf) + log.info('rpc send:', buf) end local function logRecieve(proto) if not RPCLOG then return end - log.debug('rpc recieve:', json.encode(proto)) + log.info('rpc recieve:', json.encode(proto)) end local m = {} @@ -167,8 +167,8 @@ function m.doMethod(proto) -- 任务可能在执行过程中被中断,通过close来捕获 local response = function () local passed = os.clock() - clock - if passed > 0.2 then - log.debug(('Method [%s] takes [%.3f]sec. %s'):format(method, passed, util.dump(proto, secretOption))) + if passed > 0.5 then + log.warn(('Method [%s] takes [%.3f]sec. %s'):format(method, passed, util.dump(proto, secretOption))) end --log.debug('Finish method:', method) if not proto.id then -- cgit v1.2.3 From f2db41df39000bc3ca0c93e0d2ac8b8fafaf4d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 5 Apr 2022 23:53:29 +0800 Subject: #1018 add `inspect.lua` --- script/proto/proto.lua | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'script/proto') diff --git a/script/proto/proto.lua b/script/proto/proto.lua index cb549764..d245ab65 100644 --- a/script/proto/proto.lua +++ b/script/proto/proto.lua @@ -5,6 +5,7 @@ local pub = require 'pub' local jsonrpc = require 'jsonrpc' local define = require 'proto.define' local json = require 'json' +local inspect = require 'inspect' local reqCounter = util.counter() @@ -49,7 +50,7 @@ end function m.response(id, res) if id == nil then - log.error('Response id is nil!', util.dump(res)) + log.error('Response id is nil!', inspect(res)) return end assert(m.holdon[id]) @@ -62,7 +63,7 @@ end function m.responseErr(id, code, message) if id == nil then - log.error('Response id is nil!', util.dump(message)) + log.error('Response id is nil!', inspect(message)) return end assert(m.holdon[id]) @@ -128,16 +129,14 @@ function m.request(name, params, callback) end local secretOption = { - format = { - ['text'] = function (value, _, _, stack) - if stack[1] == 'params' - and stack[2] == 'textDocument' - and stack[3] == nil then - return '"***"' - end - return ('%q'):format(value) + process = function (item, path) + if path[1] == 'params' + and path[2] == 'textDocument' + and path[3] == nil then + return '"***"' end - } + return item + end } function m.doMethod(proto) @@ -168,7 +167,7 @@ function m.doMethod(proto) local response = function () local passed = os.clock() - clock if passed > 0.5 then - log.warn(('Method [%s] takes [%.3f]sec. %s'):format(method, passed, util.dump(proto, secretOption))) + log.warn(('Method [%s] takes [%.3f]sec. %s'):format(method, passed, inspect(proto, secretOption))) end --log.debug('Finish method:', method) if not proto.id then @@ -201,7 +200,7 @@ function m.doResponse(proto) local id = proto.id local waiting = m.waiting[id] if not waiting then - log.warn('Response id not found: ' .. util.dump(proto)) + log.warn('Response id not found: ' .. inspect(proto)) return end m.waiting[id] = nil -- cgit v1.2.3