Available since v0.4.0
local log = require "log"
log.log(level, msg)Logs a message at the specified log level. The log level determines the severity of the message.
log.log(log.INFO, "This is an informational message.")
The following log levels are available:
log.TRACE: Trace-level messages, used for very detailed debugging information.log.DEBUG: Debug-level messages, useful for general debugging information.log.INFO: Informational messages, typically for general runtime events.log.WARN: Warning messages, indicating a potential issue that may not require immediate attention.log.ERROR: Error messages, representing an issue that requires immediate attention.For convenience, the package provides alias functions for each standard log level.
log.trace(msg)Logs a trace-level message, used for very detailed debugging information.
log.trace("This is a trace message.")
log.tracef("Trace message ID: %d", 10)
log.debug(msg)Logs a debug-level message, useful for general debugging information.
log.debug("This is a debugging message.")
log.debugf("Debug message ID: %d", 10)
log.info(msg)Logs an informational message, typically for general runtime events.
log.info("This is an informational message.")
log.infof("Info message ID: %d", 10)
log.warn(msg)Logs a warning message, indicating a potential issue that may not require immediate attention.
log.warn("This is a warning.")
log.warnf("Warn message ID: %d", 10)
log.error(msg)Logs an error message, representing an issue that requires immediate attention.
log.error("This is an error.")
log.errorf("Error message ID: %d", 10)
For each logging function there is a companion function that will interpolate values into the log message using Lua's string.format function.
log.infof("Hello, %s!", "World")
-- is exactly equivalent to:
log.info(string.format("Hello, %s!", "World"))