aboutsummaryrefslogtreecommitdiff
path: root/src/libjin-lua/scripts/log.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin-lua/scripts/log.lua')
-rw-r--r--src/libjin-lua/scripts/log.lua64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/libjin-lua/scripts/log.lua b/src/libjin-lua/scripts/log.lua
index a0e2310..f8ddd6d 100644
--- a/src/libjin-lua/scripts/log.lua
+++ b/src/libjin-lua/scripts/log.lua
@@ -37,11 +37,11 @@ local _tostring = tostring
local tostring = function(...)
local t = {}
for i = 1, select('#', ...) do
- local x = select(i, ...)
- if type(x) == "number" then
- x = round(x, .01)
- end
- t[#t + 1] = _tostring(x)
+ local x = select(i, ...)
+ if type(x) == "number" then
+ x = round(x, .01)
+ end
+ t[#t + 1] = _tostring(x)
end
return table.concat(t, " ")
end
@@ -50,33 +50,33 @@ end
for i, x in ipairs(modes) do
local nameupper = x.name:upper()
log[x.name] = function(...)
-
- -- Return early if we're below the log level
- if i < levels[log.level] then
- return
- end
-
- local msg = tostring(...)
- local info = debug.getinfo(2, "Sl")
- local lineinfo = info.short_src .. ":" .. info.currentline
-
- -- Output to console
- print(string.format("%s[%-6s%s]%s %s: %s",
- log.usecolor and x.color or "",
- nameupper,
- os.date("%H:%M:%S"),
- log.usecolor and "\27[0m" or "",
- lineinfo,
- msg))
-
- -- Output to log file
- if log.outfile then
- local fp = io.open(log.outfile, "a")
- local str = string.format("[%-6s%s] %s: %s\n",
- nameupper, os.date(), lineinfo, msg)
- fp:write(str)
- fp:close()
- end
+
+ -- Return early if we're below the log level
+ if i < levels[log.level] then
+ return
+ end
+
+ local msg = tostring(...)
+ local info = debug.getinfo(2, "Sl")
+ local lineinfo = info.short_src .. ":" .. info.currentline
+
+ -- Output to console
+ print(string.format("%s[%-6s%s]%s %s: %s",
+ log.usecolor and x.color or "",
+ nameupper,
+ os.date("%H:%M:%S"),
+ log.usecolor and "\27[0m" or "",
+ lineinfo,
+ msg))
+
+ -- Output to log file
+ if log.outfile then
+ local fp = io.open(log.outfile, "a")
+ local str = string.format("[%-6s%s] %s: %s\n",
+ nameupper, os.date(), lineinfo, msg)
+ fp:write(str)
+ fp:close()
+ end
end
end