core/reporters/ontology.reporter.ts

core/reporters/ontology.reporter.ts is a file in GovLab Context. 14 lines of code and 2 definitions.

import type { Logger } from "#types/ontology.types";
import { debugLine } from "#configuration/strings/ontology.strings";
import process from "node:process";

export const NOOP_LOGGER: Logger = { warn: () => {} };

export const debugLogger = function debugLogger(enabled: boolean): Logger {
    if (!enabled) {
        return NOOP_LOGGER;
    }
    return {
        warn: (message, detail) => {
            process.stderr.write(`${debugLine(message)} ${JSON.stringify(detail ?? null)}\n`);
        },
    };
};