diff options
Diffstat (limited to 'script')
-rw-r--r-- | script/core/collector.lua | 1 | ||||
-rw-r--r-- | script/proto/proto.lua | 15 | ||||
-rw-r--r-- | script/utility.lua | 15 |
3 files changed, 25 insertions, 6 deletions
diff --git a/script/core/collector.lua b/script/core/collector.lua index 2f29fc37..45dae65f 100644 --- a/script/core/collector.lua +++ b/script/core/collector.lua @@ -113,4 +113,5 @@ function m.eachRef(uri, name) end return getNext end + return m diff --git a/script/proto/proto.lua b/script/proto/proto.lua index a73e462e..2156b7fa 100644 --- a/script/proto/proto.lua +++ b/script/proto/proto.lua @@ -126,6 +126,19 @@ function m.request(name, params, callback) end 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) + end + } +} + function m.doMethod(proto) logRecieve(proto) local method, optional = m.getMethodName(proto) @@ -154,7 +167,7 @@ function m.doMethod(proto) 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))) + log.debug(('Method [%s] takes [%.3f]sec. %s'):format(method, passed, util.dump(proto, secretOption))) end --log.debug('Finish method:', method) if not proto.id then diff --git a/script/utility.lua b/script/utility.lua index 004e8066..66b769f1 100644 --- a/script/utility.lua +++ b/script/utility.lua @@ -94,8 +94,10 @@ function m.dump(tbl, option) end local lines = {} local mark = {} + local stack = {} lines[#lines+1] = '{' - local function unpack(tbl, deep) + local function unpack(tbl) + local deep = #stack mark[tbl] = (mark[tbl] or 0) + 1 local keys = {} local keymap = {} @@ -153,8 +155,9 @@ function m.dump(tbl, option) end local value = tbl[key] local tp = type(value) - if option['format'] and option['format'][key] then - lines[#lines+1] = ('%s%s%s,'):format(TAB[deep+1], keyWord, option['format'][key](value, unpack, deep+1)) + local format = option['format'] and option['format'][key] + if format then + lines[#lines+1] = ('%s%s%s,'):format(TAB[deep+1], keyWord, format(value, unpack, deep+1, stack)) elseif tp == 'table' then if mark[value] and mark[value] > 0 then lines[#lines+1] = ('%s%s%s,'):format(TAB[deep+1], keyWord, option['loop'] or '"<Loop>"') @@ -162,7 +165,9 @@ function m.dump(tbl, option) lines[#lines+1] = ('%s%s%s,'):format(TAB[deep+1], keyWord, '"<Deep>"') else lines[#lines+1] = ('%s%s{'):format(TAB[deep+1], keyWord) - unpack(value, deep+1) + stack[#stack+1] = key + unpack(value) + stack[#stack] = nil lines[#lines+1] = ('%s},'):format(TAB[deep+1]) end elseif tp == 'string' then @@ -176,7 +181,7 @@ function m.dump(tbl, option) end mark[tbl] = mark[tbl] - 1 end - unpack(tbl, 0) + unpack(tbl) lines[#lines+1] = '}' return tableConcat(lines, '\r\n') end |