nparams
=
0
,
lua中需要打印行号多半是日志需求,下面是一个demo:
local logger_api = require 'common.logger_api'
local tag = "test"
local test_id = 0
local M = {}
local function get_debuginfo(info)
--utils.var_dump(info)
local d = ""
if info ~= nil and info.short_src ~= nil and info.currentline ~= nil then
d = info.short_src .. ":" .. info.currentline .. ":"
return d
function M.ELOG(...)
local info = debug.getinfo(2)
local d = get_debuginfo(info)
logger_api.ERROR(string.format("%s[E]no_%s_%s",d,test_id,tag),...)
function M.WLOG(...)
local info = debug.getinfo(2)
local d = get_debuginfo(info)
logger_api.WARN(string.format("%s[W]no_%s_%s",d,test_id,tag),...)
function M.NLOG(...)
logger_api.INFO(string.format("[N]no_%s_%s", test_id,tag), ...)
function M.DLOG(...)
local info = debug.getinfo(2)
local d = get_debuginfo(info)
logger_api.DEBUG(string.format("%s[D]no_%s_%s",d,test_id,tag),...)
return M