"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createLogger = createLogger;
exports.setLogLevel = setLogLevel;
const pino_1 = __importDefault(require("pino"));
const DEFAULT_LEVEL = process.env.LOG_LEVEL ?? 'info';
const useJson = process.env.LOG_JSON === '1';
const logger = (0, pino_1.default)({
    level: DEFAULT_LEVEL,
    ...(!useJson && {
        transport: {
            target: 'pino-pretty',
            options: { singleLine: true },
        },
    }),
});
exports.default = logger;
/** Create a child logger with a component name. */
function createLogger(component) {
    return logger.child({ component });
}
/** Set log level at runtime (e.g., from --log-level CLI flag). */
function setLogLevel(level) {
    logger.level = level;
}
