Petrichor.Log
Petrichor.Log writes tagged messages to the game log.
Loading#
Functions#
Log.info(tag, msg)#
Writes an informational message.
| Parameter | Type | Description |
|---|---|---|
tag | string | Short identifier for your mod or subsystem (e.g. "my-mod") |
msg | string | The message body |
Log.warn(tag, msg)#
Writes a warning message. The output is prefixed with [warn].
Log.debug(tag, msg)#
Writes a debug message. Used by Petrichor.Standard when log(Levels.DEBUG, ...).
Log.err(tag, msg)#
Writes an error message. The output is prefixed with [err].
Conventions#
- Keep
tagshort and consistent. It appears on every line. - Use
Log.infofor normal lifecycle events (mod loaded, hook fired once, etc.). - Use
Log.warnfor unexpected but recoverable situations. - Use
Log.errfor failures. The mod keeps running, no exception is thrown.
local Mixin = require("Augment.Mixin")
local Log = require("Petrichor.Log")
local TAG = "cow-patch"
Log.info(TAG, "registering hooks")
local ok = Mixin.register("daCow_c::Execute", "before", function(ctx)
Log.info(TAG, "cow Execute fired")
end, 0, TAG)
if not ok then
Log.err(TAG, "failed to register daCow_c::Execute hook")
end
import * as Mixin from "Augment.Mixin"
import * as Log from "Petrichor.Log"
const TAG = "cow-patch"
Log.info(TAG, "registering hooks")
const ok = Mixin.register("daCow_c::Execute", "before", (ctx) => {
Log.info(TAG, "cow Execute fired")
}, 0, TAG)
if (!ok) {
Log.err(TAG, "failed to register daCow_c::Execute hook")
}