"use strict";
/*
 * @adonisjs/logger
 *
 * (c) Harminder Virk <virk@adonisjs.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPino = void 0;
/// <reference path="../adonis-typings/logger.ts" />
const pino_1 = __importDefault(require("pino"));
/**
 * Mapping pino timestamp formatters to keywords
 */
const TimestampFormatters = {
    iso: pino_1.default.stdTimeFunctions.isoTime,
    epoch: pino_1.default.stdTimeFunctions.epochTime,
    unix: pino_1.default.stdTimeFunctions.unixTime,
};
/**
 * Returns an instance of pino logger by adjusting the config options
 */
function getPino(options) {
    const pinoOptions = Object.assign({}, options);
    /**
     * Use pino formatters when a keyword is used
     */
    if (pinoOptions.timestamp &&
        typeof pinoOptions.timestamp === 'string' &&
        TimestampFormatters[pinoOptions.timestamp]) {
        pinoOptions.timestamp = TimestampFormatters[pinoOptions.timestamp];
    }
    return options.stream ? (0, pino_1.default)(pinoOptions, options.stream) : (0, pino_1.default)(pinoOptions);
}
exports.getPino = getPino;
