quickserver icon indicating copy to clipboard operation
quickserver copied to clipboard

终端log输出

Open dwdcth opened this issue 11 years ago • 2 comments

希望提供终端log输出的功能。

dwdcth avatar Jan 07 '15 03:01 dwdcth

Hi,

src/framework/debug.lua 文件中,有这样几个函数:

if CCLuaLog then
    io.output():setvbuf('no')
elseif ngx and ngx.log then
    print = function(...)
        local arg = {...}
        for k,v in pairs(arg) do
            arg[k] = tostring(v)
        end
        ngx.log(ngx.ERR, table.concat(arg, "\t"))
    end
end

echo = print

function echoError(fmt, ...)
    echoLog("ERR", fmt, ...)
    print(debug.traceback("", 2))
end

function echoInfo(fmt, ...)
    echoLog("INFO", fmt, ...)
end

function echoLog(tag, fmt, ...)
    echo(string.format("[%s] %s", string.upper(tostring(tag)), string.format(tostring(fmt), ...)))
end

你可以使用它们输出你想要的内容,并且在安装后的的Quick Server路径下的 openresty/nginx/log/error.log里看到内容:)

cheerayhuang avatar Jan 08 '15 06:01 cheerayhuang

加入 FAQ

dualface avatar Mar 26 '15 01:03 dualface