For logging debug information to files.
local Logger = require('__stdlib__/stdlib/misc/logger')
-- or to create a new logger directly:
local Log = require('__stdlib__/stdlib/misc/logger').new()
-- log files are saved to script-output/modname/log.log by default
Log.log(msg) | Logs a message. |
Log.write() | Writes out all buffered messages immediately. |
get(...) | Get a saved log or create a new one if there is no saved log. |
new([log_name='log'][, debug_mode=false][, options={...}]) | Creates a new logger object. |
Log.options | Used in the new function for logging game ticks, specifying logfile extension, or forcing the logs to append to the end of the logfile. |
Logs a message.
Parameters:
Writes out all buffered messages immediately.
Returns:
Get a saved log or create a new one if there is no saved log.
Parameters:
Creates a new logger object.
In debug mode, the logger writes to file immediately, otherwise the logger buffers the lines.
The logger flushes the logged messages every 60 seconds since the last message.
A table of options may be specified when creating a logger.
Parameters:Log = Logger.new()
Log("this msg will be logged in /script-output/YourModName/log.log!")
-- Immediately Write everything buffered in the log file
Log()
Log = Logger.new('test', true)
Log("this msg will be logged and written immediately in /script-output/YourModName/test.log!")
Log = Logger.new('cool_mod_name', 'test', true, { file_extension = data })
Log("this msg will be logged and written immediately in /script-output/YourModName/test.data!")
Used in the new function for logging game ticks, specifying logfile extension, or forcing the logs to append to the end of the logfile.
Fields: