"use strict";
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createLogger = exports.Logger = void 0;
const pino_1 = __importDefault(require("pino"));
const pino_multi_stream_1 = __importDefault(require("pino-multi-stream"));
const pinoSentry = __importStar(require("@graphprotocol/pino-sentry-simple"));
class Logger {
    constructor(options) {
        this.options = options;
        const loggerOptions = { name: options.name, level: options.level || 'debug' };
        const stream = options.async
            ? pino_1.default.destination({ minLength: 4096, sync: false })
            : pino_1.default.destination();
        if (options.sentry) {
            const streams = [
                { stream, level: loggerOptions.level },
                {
                    stream: options.async
                        ? pinoSentry.createWriteStreamAsync(Object.assign({}, options.sentry))
                        : pinoSentry.createWriteStream(Object.assign({}, options.sentry)),
                },
            ];
            this.inner = pino_multi_stream_1.default(Object.assign(Object.assign({}, loggerOptions), { streams }));
        }
        else {
            this.inner = pino_1.default(loggerOptions, stream);
        }
    }
    child(bindings) {
        const inner = this.inner.child(bindings);
        const logger = new Logger(this.options);
        logger.inner = inner;
        return logger;
    }
    trace(msg, o, ...args) {
        if (o) {
            this.inner.trace(o, msg, ...args);
        }
        else {
            this.inner.trace(msg, ...args);
        }
    }
    debug(msg, o, ...args) {
        if (o) {
            this.inner.debug(o, msg, ...args);
        }
        else {
            this.inner.debug(msg, ...args);
        }
    }
    info(msg, o, ...args) {
        if (o) {
            this.inner.info(o, msg, ...args);
        }
        else {
            this.inner.info(msg, ...args);
        }
    }
    warn(msg, o, ...args) {
        if (o) {
            this.inner.warn(o, msg, ...args);
        }
        else {
            this.inner.warn(msg, ...args);
        }
    }
    warning(msg, o, ...args) {
        if (o) {
            this.inner.warn(o, msg, ...args);
        }
        else {
            this.inner.warn(msg, ...args);
        }
    }
    error(msg, o, ...args) {
        if (o) {
            this.inner.error(o, msg, ...args);
        }
        else {
            this.inner.error(msg, ...args);
        }
    }
    fatal(msg, o, ...args) {
        if (o) {
            this.inner.fatal(o, msg, ...args);
        }
        else {
            this.inner.fatal(msg, ...args);
        }
    }
    crit(msg, o, ...args) {
        if (o) {
            this.inner.fatal(o, msg, ...args);
        }
        else {
            this.inner.fatal(msg, ...args);
        }
    }
    critical(msg, o, ...args) {
        if (o) {
            this.inner.fatal(o, msg, ...args);
        }
        else {
            this.inner.fatal(msg, ...args);
        }
    }
}
exports.Logger = Logger;
exports.createLogger = (options) => new Logger(options);
//# sourceMappingURL=index.js.map