diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-06 00:25:14 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-06 00:25:14 +0800 |
commit | 21d1b8fd59bcfff3797453e787a1151f8987ae0b (patch) | |
tree | 0e146319e02373c2a90d307c1c06e4af562c57b5 /script/proto | |
parent | d308b37e66d01737d5079b5a062127cdfcba47b1 (diff) | |
parent | 63b360689f0c2c99a1ae410518f6866f49972f98 (diff) | |
download | lua-language-server-21d1b8fd59bcfff3797453e787a1151f8987ae0b.zip |
Merge commit '63b360689f0c2c99a1ae410518f6866f49972f98' into 3.0
Diffstat (limited to 'script/proto')
-rw-r--r-- | script/proto/proto.lua | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/script/proto/proto.lua b/script/proto/proto.lua index 83a188f9..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() @@ -12,14 +13,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 = {} @@ -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) @@ -167,8 +166,8 @@ function m.doMethod(proto) -- 任务可能在执行过程中被中断,通过close来捕获 local response <close> = 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, 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 |