Skip to content

Commit

Permalink
Merge branch 'hanxi:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
huahua132 authored Nov 9, 2023
2 parents 1bbc1c5 + a70ca11 commit 1ec7f68
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion 3rd/lua-rax
Submodule lua-rax updated 2 files
+5 −4 lua_rax.c
+4 −3 rax.lua
49 changes: 25 additions & 24 deletions lualib/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,51 @@ local traceback = debug.traceback

local M = {}
local levels = {
debug = 1,
info = 2,
warn = 3,
error = 4,
debug = 1,
info = 2,
warn = 3,
error = 4,
}
local level = config.get("wlua_loglevel", "debug")
local loglevel = levels[level]

function M.is_debug()
if levels.debug < loglevel then return end
return true
if levels.debug < loglevel then return end
return true
end

function M.debug(...)
if levels.debug < loglevel then return end
local tbl = {}
for i,v in pairs({...}) do
if type(v) == "table" then
tbl[i] = util_table.tostring(v)
else
tbl[i] = tostring(v)
end
end
skynet.error("[DEBUG]", table.concat(tbl, " "))
if levels.debug < loglevel then return end
local tbl = {}
for i = 1, select('#', ...) do
local v = select(i, ...)
if type(v) == "table" then
tbl[i] = util_table.tostring(v)
else
tbl[i] = tostring(v) or "nil"
end
end
skynet.error("[DEBUG]", table.concat(tbl, " "))
end

function M.info(...)
if levels.info < loglevel then return end
skynet.error("[INFO]", ...)
if levels.info < loglevel then return end
skynet.error("[INFO]", ...)
end

function M.warn(...)
if levels.warn < loglevel then return end
skynet.error("[WARN]", ...)
if levels.warn < loglevel then return end
skynet.error("[WARN]", ...)
end

function M.error(...)
if levels.error < loglevel then return end
skynet.error("[ERROR]", ...)
skynet.error("[ERROR]", traceback())
if levels.error < loglevel then return end
skynet.error("[ERROR]", ...)
skynet.error("[ERROR]", traceback())
end

function M.log(...)
skynet.error(...)
skynet.error(...)
end

return M

0 comments on commit 1ec7f68

Please sign in to comment.