From da83f37c216757814935f4deb313c9f066880996 Mon Sep 17 00:00:00 2001 From: sumneko Date: Wed, 5 Jun 2019 11:15:49 +0800 Subject: =?UTF-8?q?=E5=90=AF=E5=8A=A8=E8=B0=83=E8=AF=95=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/debugger.lua | 20 ++++++++++++-------- server/main.lua | 3 ++- server/src/log.lua | 5 +++-- 3 files changed, 17 insertions(+), 11 deletions(-) (limited to 'server') diff --git a/server/debugger.lua b/server/debugger.lua index c14cfaea..76266313 100644 --- a/server/debugger.lua +++ b/server/debugger.lua @@ -34,18 +34,22 @@ table.sort(luaDebugs, function (a, b) end) local debugPath = extensionPath / luaDebugs[1] -local cpath = "runtime/win64/lua54/?.dll" -local path = "script/?.lua" +local cpath = "/runtime/win64/lua54/?.dll" +local path = "/script/?.lua" -package.cpath = package.cpath .. ';' .. (debugPath / cpath):string() +package.cpath = package.cpath .. ';' .. debugPath:string() .. cpath local function tryDebugger() local rdebug = require "remotedebug" - local entry = package.searchpath('start_debug', (debugPath / path):string()) - local dbg = loadfile(entry)(rdebug, debugPath:string() .. '/', path, cpath) - local port = "11411" - dbg:start("listen:127.0.0.1:" .. port, true) - log.debug('Debugger startup, listen port:', port) + local entry = package.searchpath('start_debug', debugPath:string() .. path) + local root = debugPath:string() + local pid = "11411" + local addr = ("@%s/runtime/tmp/pid_%s.tmp"):format(root, pid) + local dbg = loadfile(entry)(rdebug, root, path, cpath) + debug.getregistry()["lua-debug"] = dbg + dbg:start(addr, true) + log.debug('Debugger startup, listen port:', pid) + log.debug('Args:', addr, rdebug, root, path, cpath) end xpcall(tryDebugger, log.debug) diff --git a/server/main.lua b/server/main.lua index c9b51239..d1673836 100644 --- a/server/main.lua +++ b/server/main.lua @@ -19,9 +19,10 @@ collectgarbage("setstepmul", 1000) log = require 'log' log.init(ROOT, ROOT / 'log' / 'service.log') log.info('Lua Lsp startup, root: ', ROOT) +log.debug('ROOT:', ROOT:string()) ac = {} ---xpcall(dofile, log.debug, rootPath .. 'debugger.lua') +xpcall(dofile, log.debug, rootPath .. 'debugger.lua') require 'utility' require 'global_protect' local service = require 'service' diff --git a/server/src/log.lua b/server/src/log.lua index af4212e1..7ebb55cf 100644 --- a/server/src/log.lua +++ b/server/src/log.lua @@ -8,7 +8,8 @@ log.size = 0 log.max_size = 100 * 1024 * 1024 local function trim_src(src) - src = src:sub(log.prefix_len, -5) + src = src:sub(log.prefix_len + 1, -5) + src = src:gsub('^[/\\]+', '') src = src:gsub('[\\/]+', '.') return src end @@ -98,7 +99,7 @@ function log.init(root, path) end end log.path = path:string() - log.prefix_len = #root:string() + 3 + log.prefix_len = #root:string() log.size = 0 if not fs.exists(path:parent_path()) then fs.create_directories(path:parent_path()) -- cgit v1.2.3