Provides test-time access to the shared Winston logger used by the framework.
Expose the same logger instance that the application and framework use so tests can:
- Emit logs for debugging
- Integrate with
LogCaptureHookandLogMatchHookto assert log behavior - Control level via environment (
LOG_LEVEL)
import {describe, it} from "node:test";
import assert from "node:assert/strict";
import {useNodeBoot} from "@nodeboot/node-test";
import {EmptyApp} from "../src/empty-app";
describe("LoggerHook - Basic", () => {
const {useLogger} = useNodeBoot(EmptyApp, () => {});
it("emits logs", () => {
const logger = useLogger();
logger.info("hello from test");
assert.ok(true);
});
});- Combine with
LogCaptureHookto capture emitted logs for assertions. - Use
LogMatchHookto assert presence/absence of patterns.
const logger = useLogger(); // returns winston.Logger
logger.info("message");
logger.warn("warning");
logger.error("error");- Level is controlled via
process.env.LOG_LEVEL(default:debug).
- If logs don’t appear in capture/match hooks, ensure those hooks are activated in setup and that
LOG_LEVELisn’t filtering them out.