Appearance
@loontail/minecraft-kit v0.8.14 / scopedLogger
Function: scopedLogger()
ts
function scopedLogger(
base,
scope,
baseFields?): LoggerWrap a Logger so every message is prefixed with [scope]. Mirrors the scopedLogger(scope) convention used by the launcher: each module reaches for one named logger at the top of the file (e.g. const log = scopedLogger(input.logger, "http")) instead of threading the scope through every callsite.
The merged fields argument lets a scope attach default context (e.g. a request id) without the call site repeating it on every message.
Parameters
| Parameter | Type |
|---|---|
base | Logger |
scope | string |
baseFields? | Readonly<Record<string, unknown>> |
Returns
Example
ts
import { consoleLogger, scopedLogger } from "@loontail/minecraft-kit";
const log = scopedLogger(consoleLogger, "fabric-installer", { profileId: "fabric-loader-0.15.7" });
log.log("info", "patching profile");
// → [info] [fabric-installer] patching profile { profileId: "fabric-loader-0.15.7" }