The building blocks of ZTracer.
Groups visually separate log categories. Each group can have a background and text color.
const logger = new ZTracer({
groups: {
api: { background: "#0d6efd", color: "#fff" },
db: { background: "#198754", color: "#fff" }
}
});
await logger.log("User logged in", { group: "api" });
If a group is not defined, ZTracer renders it with a default gray style. See the API Reference for full group configuration.
A suffix is an optional label appended to the group name. Useful for distinguishing multiple logs in the same group.
await logger.log("Request #1", { group: "api", suffix: "req-1" });
await logger.log("Request #2", { group: "api", suffix: "req-2" });
Console output: api req-1 and api req-2.
The debug flag controls console output only.
Callbacks always run, even when debug: false.
{
global: {
debug: false, // No console output
callBack: async (data) => { /* still runs */ }
}
}
This is useful for production telemetry — see the Log Lifecycle page for details.
Logs structured data: arrays as tables (console.table),
objects as expandable directories (console.dir).
await logger.fromJson([
{ id: 1, name: "Alice" }
], { group: "db" });
For more examples, visit the Examples page.
Measures execution time of async or sync functions. Each timer gets a unique label.
await logger.time(async () => {
await fetch("https://api.example.com");
}, { group: "api" });
Every log passes through 4 stages in order:
debug: trueoptionsFor a detailed explanation with examples, see the Log Lifecycle page.