mintmousse.addLogSink
Used to add a custom sink to direct log messages to where ever you want, for the current thread that the function is ran on.
I recommend checking out the logging sinks that the library implements to fully understand how you can implement your own.
Thread behaviour
This function is used to route logs of the thread that this function is ran on. If you just want to set a logging sink once, and handle all logs from all threads see mintmousse.addGlobalLogSink. This function is recommended over global sinks for performance.
Synopsis
Parameters
sinkfunction- A function, with the signature
(level, logger, time, debugInfo, message...). See below for details flushFuncfunction- A function, with the signature
(forced). Seemintmousse.flushLogsfor details
Sink Function Signature
levellevel- A string indicating the level of the log,
"info","warning","error","fatal","debug". loggerlogger-
The logger that created the log.
You shouldn't try to use any other function of the logger when it is in a sink other than
(Logger):getAncestryand(Logger).inspect. timenumber- UNIX time in seconds, with microseconds. By default, this value is obtained by
socket.gettimeto get an accurate system time. debugInfostring or nil- Depending on the level, and the config -- TODO link, a simple traceback string is passed along the lines of
funcName@fileName#lineNumber, this format isn't guaranteed, for example code in the file scope will befileName#lineNumberas they aren't contained within a named function. message...ANY- The varargs of the message passed from the log function.
Returns
Nothing.
Examples
mintmousse.addLogSink(
function(level, logger, time, debugInfo, ...) -- Sink function
if (level == "info" or info == "warning") and
and math.floor(time) and not debugInfo then
local num = select('#', ...)
io.stdout:write(num .. "\n")
end
end,
function(forced) -- Flush function
io.stdout:flush()
end
)
logger:info("Hello", "World", 0, nil, { }) -- 6\n
logger:warning("Foo", "Bar") -- 2\n
mintmousse.flushLogs()