summaryrefslogtreecommitdiff
path: root/script/proto/proto.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/proto/proto.lua')
-rw-r--r--script/proto/proto.lua31
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