Mod Logger

Description

Description 🔗

Mod that wraps around the core logger. It adds extra functions & standardized logging output messages.

Usage 🔗

Adds a single global function register_mod_logger:

register_mod_logger()
register_mod_logger(name)
register_mod_logger(logger)
register_mod_logger(name, logger)
- name: (optional) Logger name that will prefix messages. If omitted, mod name will be used.
- logger: (optional) Table to which logging functions will be added. If omitted, a new table will be created
    & returned.
- return value: `logger` or new table with logging functions.

Once registered, the logger table will include the following functions:

Functions:

  • log(lvl, msg)
  • log(msg)
  • info(msg)
  • action(msg)
  • warn(msg)
  • error(msg)
  • debug(msg)

Parameters:

  • 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".
  • msg: Logging message text.

Settings 🔗

Note: Messages also abide by level of core Luanti logger. "info" & "debug" messages are output to the default core logger level.

Examples 🔗

Using as hard dependency:

my_mod = {}
register_mod_logger(my_mod)

Using as soft dependency:

my_mod = {
    -- only need to add functions that will be used
    log = function() end,
    info = function() end,
    action = function() end,
    warn = function() end,
    error = function() end,
    debug = function() end
}
if core.global_exists("register_mod_logger") then
    register_mod_logger(my_mod)
end

Calling logging functions:

-- 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!")

Creating a local logger:

local my_logger = register_mod_logger()
my_logger.info("Hello my_mod!")

TODO 🔗

Similar Mods 🔗

  • logging

Reviews

Review

Do you recommend this mod?

  • No reviews, yet.

Releases

2026-06-08

Download

Luanti 5.0+

15 hours ago

2026-06-08 🔗

Initial release.

All releases