mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 19:13:49 +01:00
Add padding to level names in log messages.
Other minor changes.
This commit is contained in:
parent
759c0a3007
commit
4f84e1060b
@ -170,7 +170,7 @@ function M:send()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self.body.status ~= "success" then
|
if self.body.status ~= "success" then
|
||||||
log:verbose(MOD_ABBR, "Response: "..utils.dump(self.body.status).." ("..utils.dump(self.body.msg)..")")
|
log:warning(MOD_ABBR, "Response status: "..utils.dump(self.body.status).." ("..utils.dump(self.body.msg)..")")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,7 +54,8 @@ local DEFAULT_FILTERSET = {
|
|||||||
['patterns'] = {
|
['patterns'] = {
|
||||||
['%(error%)'] = 'red',
|
['%(error%)'] = 'red',
|
||||||
['%(warning%)'] = 'yellow',
|
['%(warning%)'] = 'yellow',
|
||||||
['%(bulk%)'] = 'gray'
|
['%(bulk%)'] = 'gray',
|
||||||
|
['setState%(%)'] = 'bblue'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ local M = {}
|
|||||||
|
|
||||||
local logLevel, logVerboseFmt, logStream
|
local logLevel, logVerboseFmt, logStream
|
||||||
|
|
||||||
|
local LONGEST_LEVEL_NAME = -1
|
||||||
|
|
||||||
--- Available log levels (starting at 1)
|
--- Available log levels (starting at 1)
|
||||||
-- @table LEVEL
|
-- @table LEVEL
|
||||||
M.LEVEL = {
|
M.LEVEL = {
|
||||||
@ -26,12 +28,19 @@ M.LEVEL = {
|
|||||||
'bulk' -- debug information (in large amounts)
|
'bulk' -- debug information (in large amounts)
|
||||||
}
|
}
|
||||||
|
|
||||||
-- M.LEVEL already has idx=>name entries, now create name=>idx entries so it can be indexed both ways
|
|
||||||
|
--[[== module initialization code ==]]--
|
||||||
|
|
||||||
|
-- M.LEVEL already has idx=>name entries, now create name=>idx entries so it can be indexed both ways, and init LONGEST_LEVEL_NAME
|
||||||
for i,v in ipairs(M.LEVEL) do
|
for i,v in ipairs(M.LEVEL) do
|
||||||
M.LEVEL[v] = i
|
M.LEVEL[v] = i
|
||||||
|
if v:len() > LONGEST_LEVEL_NAME then LONGEST_LEVEL_NAME = v:len() end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--[[================================]]--
|
||||||
|
|
||||||
|
|
||||||
local function log(level, module, msg, verboseFmt)
|
local function log(level, module, msg, verboseFmt)
|
||||||
if level <= logLevel then
|
if level <= logLevel then
|
||||||
local now = os.date('%m-%d %H:%M:%S')
|
local now = os.date('%m-%d %H:%M:%S')
|
||||||
@ -43,8 +52,11 @@ local function log(level, module, msg, verboseFmt)
|
|||||||
local m = (type(msg) == 'string') and msg or utils.dump(msg)
|
local m = (type(msg) == 'string') and msg or utils.dump(msg)
|
||||||
if module == nil then module = "LUA " end
|
if module == nil then module = "LUA " end
|
||||||
|
|
||||||
if v then logStream:write(now .. " [" .. module .. "] (" .. M.LEVEL[level] .. "): " .. m .. " [" .. name .. "@" .. i.short_src .. ":" .. i.linedefined .. "]\n")
|
local levelName = M.LEVEL[level]
|
||||||
else logStream:write(now .. " [" .. module .. "] (" .. M.LEVEL[level] .. "): " .. m .. "\n") end
|
local padding = string.rep(' ', LONGEST_LEVEL_NAME - levelName:len())
|
||||||
|
|
||||||
|
if v then logStream:write(now .. " [" .. module .. "] (" .. levelName .. ")" .. padding .. ": " .. m .. " [" .. name .. "@" .. i.short_src .. ":" .. i.linedefined .. "]\n")
|
||||||
|
else logStream:write(now .. " [" .. module .. "] (" .. levelName .. ")" .. padding .. ": " .. m .. "\n") end
|
||||||
|
|
||||||
logStream:flush()
|
logStream:flush()
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user