{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreievnr574ptp2lcbqs36jzknm52lljjets2hckqnutksucgkqypsum",
"uri": "at://did:plc:pvz7ox4x2ehjiezsahttqyyz/app.bsky.feed.post/3mnsmpjxqec22"
},
"path": "/viewtopic.php?p=451457#p451457",
"publishedAt": "2026-06-08T21:18:11.000Z",
"site": "https://forum.luanti.org",
"tags": [
"Codeberg",
"GitHub",
"GitLab",
"AntumDeluge"
],
"textContent": "Description\n\nMod that wraps around the core logger. It adds extra functions & standardized logging output messages.\n\nUsage\n\nAdds a single global function `register_mod_logger`:\n\nregister_mod_logger([mod_table])\n\n * mod_table: Table to which logging functions will be added. If omitted, a new table will be created & returned.\n * return value: `mod_table` or new table with logging functions.\n\nOnce registered, the `mod_table` will include the following functions:\n\n**Functions:**\n\n\n * log(lvl, msg)\n * log(msg)\n * info(msg)\n * action(msg)\n * warn(msg)\n * error(msg)\n * debug(msg)\n\n**Parameters:**\n\n\n * lvl: (optional) Logging level. Can be one of \"error\", \"warn\", \"action\", \"info\", or \"debug\". If its value is `nil` the standard message logging level will be used (same as `log(msg)`). \"warning\" is alias of \"warn\".\n * msg: Logging message text.\n\nLogging verbosity can be set with the `mod_log_level` setting. Logging levels, other than `debug`,\nalso abide by level of core Luanti logger.\n\n**Examples:**\n\nUsing as hard dependency:\n\n\nCode:\n\n\n my_mod = {}register_mod_logger(my_mod)\n\nUsing as soft dependency:\n\n\nCode:\n\n\n my_mod = { -- only need to add functions that will be used log = function(lvl, msg) end, info = function(msg) end, action = function(msg) end, warn = function(msg) end, error = function(msg) end, debug = function(msg) end}if core.global_exists(\"register_mod_logger\") then register_mod_logger(my_mod)end\n\nCalling logging functions:\n\n\nCode:\n\n\n -- outputs \"[<mod_name>] Hello my_mod!\" to Luanti logging console-- same as `my_mod.log(\"Hello my_mod!\")` or `my_mod.log(nil, \"Hello my_mod!)`my_mod.info(\"Hello my_mod!\")-- outputs \"DEBUG[<mod_name>] Hello my_mod!\" to Luanti logging console-- same as `my_mod.log(\"debug\", \"Hello my_mod!\")`my_mod.debug(\"Hello my_mod!\")\n\nCreating a local logger:\n\n\nCode:\n\n\n local my_logger = register_mod_logger()my_logger.info(\"Hello my_mod!\")\n\nLinks\n\n\n * Git Repo Mirros:\n * Codeberg\n * GitHub\n * GitLab\n\n\n\nStatistics: Posted by AntumDeluge — Mon Jun 08, 2026 21:18\n\n* * *",
"title": "WIP Mods • [mod] Mod Logger [mod_logger]",
"updatedAt": "2026-06-08T21:18:11.000Z"
}