mirror of
https://github.com/mrSkortch/MissionScriptingTools.git
synced 2025-08-15 10:47:23 +00:00
added msg log function
This commit is contained in:
parent
a11b254bbd
commit
9dd046dbce
33
mist.lua
33
mist.lua
@ -845,7 +845,7 @@ do -- the main scope
|
|||||||
table.remove(scheduledTasks, i)
|
table.remove(scheduledTasks, i)
|
||||||
local err, errmsg = pcall(task.f, unpack(task.vars, 1, table.maxn(task.vars)))
|
local err, errmsg = pcall(task.f, unpack(task.vars, 1, table.maxn(task.vars)))
|
||||||
if not err then
|
if not err then
|
||||||
log:error('mist.scheduleFunction, error in scheduled function: $1', errmsg)
|
log:error('Error in scheduled function: $1', errmsg)
|
||||||
end
|
end
|
||||||
--task.f(unpack(task.vars, 1, table.maxn(task.vars))) -- do the task, do not increment i
|
--task.f(unpack(task.vars, 1, table.maxn(task.vars))) -- do the task, do not increment i
|
||||||
else
|
else
|
||||||
@ -859,7 +859,7 @@ do -- the main scope
|
|||||||
task.t = timer.getTime() + task.rep --schedule next run
|
task.t = timer.getTime() + task.rep --schedule next run
|
||||||
local err, errmsg = pcall(task.f, unpack(task.vars, 1, table.maxn(task.vars)))
|
local err, errmsg = pcall(task.f, unpack(task.vars, 1, table.maxn(task.vars)))
|
||||||
if not err then
|
if not err then
|
||||||
log:error('mist.scheduleFunction, error in scheduled function: $1' .. errmsg)
|
log:error('Error in scheduled function: $1' .. errmsg)
|
||||||
end
|
end
|
||||||
--scheduledTasks[i].f(unpack(scheduledTasks[i].vars, 1, table.maxn(scheduledTasks[i].vars))) -- do the task
|
--scheduledTasks[i].f(unpack(scheduledTasks[i].vars, 1, table.maxn(scheduledTasks[i].vars))) -- do the task
|
||||||
i = i + 1
|
i = i + 1
|
||||||
@ -965,9 +965,10 @@ do -- the main scope
|
|||||||
function mist.init()
|
function mist.init()
|
||||||
-- create logger
|
-- create logger
|
||||||
mist.log = mist.Logger:new("MIST")
|
mist.log = mist.Logger:new("MIST")
|
||||||
log = mist.log
|
log = mist.log -- log shorthand
|
||||||
-- set info log level
|
-- set warning log level, showing only
|
||||||
log:setLevel("info")
|
-- warnings and errors
|
||||||
|
log:setLevel("warning")
|
||||||
|
|
||||||
log:info("initializing databases")
|
log:info("initializing databases")
|
||||||
initDBs()
|
initDBs()
|
||||||
@ -979,7 +980,7 @@ do -- the main scope
|
|||||||
-- call main the first time therafter it reschedules itself.
|
-- call main the first time therafter it reschedules itself.
|
||||||
mist.main()
|
mist.main()
|
||||||
|
|
||||||
log:info('MIST version $1.$2.$3 loaded', mist.majorVersion, mist.minorVersion, mist.build)
|
log:msg('MIST version $1.$2.$3 loaded', mist.majorVersion, mist.minorVersion, mist.build)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- The main function.
|
--- The main function.
|
||||||
@ -6495,6 +6496,26 @@ do -- mist.Logger scope
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Logs a message, disregarding the log level.
|
||||||
|
-- @tparam string text the text with keywords to substitute.
|
||||||
|
-- @param ... variables to be used for substitution.
|
||||||
|
-- @usage myLogger:msg("Always logged!")
|
||||||
|
function mist.Logger:msg(text, ...)
|
||||||
|
text = formatText(text, unpack(arg))
|
||||||
|
if text:len() > 4000 then
|
||||||
|
local texts = splitText(text)
|
||||||
|
for i = 1, #texts do
|
||||||
|
if i == 1 then
|
||||||
|
env.info(self.tag .. '|' .. texts[i])
|
||||||
|
else
|
||||||
|
env.info(texts[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
env.info(self.tag .. '|' .. text)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Logs an error.
|
--- Logs an error.
|
||||||
-- logs a message prefixed with this loggers tag to dcs.log as
|
-- logs a message prefixed with this loggers tag to dcs.log as
|
||||||
-- long as at least the "error" log level (1) is set.
|
-- long as at least the "error" log level (1) is set.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user