Log
Log - is a single file Lua library for Defold game engine, enabling efficient logging for game development. It simplifies debugging and monitoring by allowing developers to generate detailed logs that can be adjusted for different stages of development.
Features
- Log Levels: Includes TRACE, DEBUG, INFO, WARN, and ERROR for varied detail in logging.
- Build-specific Logging: Allows changing log verbosity between debug and release builds.
- Detailed Context: Supports logging with additional information for context, such as variable values or state information.
- Format Customization: Allows customizing the log message format.
- Performance Tracking: Provides features to log execution time and memory use.
Setup
See the Defold-Log repository on Github for the Setup, Documentation, API and Use Cases
Usage
-- Import log module first
local log = require("log.log")
-- Create a logger instance to use in this file
local logger = log.get_logger("my_logger_name")
function init(self)
-- All available functions in logger instance:
logger:trace("Trace is typically used to log the start and end of functions or specific events")
logger:debug("Debug is suitable for detailed system information that could be helpful during development", { level = self.level, message = "any_param" })
logger:info("Info is used for general system information under normal operation")
logger:warn("Warn is intended for potentially harmful situations that could require attention")
logger:error("Error indicates serious issues that have occurred and should be addressed immediately", { error = "error message" })
end