const LEVEL_ORDER = {
    debug: 0,
    info: 1,
    warn: 2,
    error: 3,
};
export function createLogger(level) {
    const threshold = LEVEL_ORDER[level];
    function emit(lvl, tag, msg, err) {
        if (LEVEL_ORDER[lvl] < threshold)
            return;
        const ts = new Date().toISOString();
        const label = lvl.toUpperCase();
        console.error(`[${ts}] [${label}] [${tag}] ${msg}`);
        if (err) {
            console.error(err.stack ?? err.message);
        }
    }
    return {
        debug: (tag, msg) => emit('debug', tag, msg),
        info: (tag, msg) => emit('info', tag, msg),
        warn: (tag, msg) => emit('warn', tag, msg),
        error: (tag, msg, err) => emit('error', tag, msg, err),
    };
}
//# sourceMappingURL=logger.js.map