"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.expressLogger = void 0;
const context_1 = require("../context/context");
const logger_1 = require("./logger");
const tracing_1 = require("../tracing");
const context_2 = require("./context");
const types_1 = require("./types");
const expressLogger = (service) => {
    return (req, response, next) => {
        if (!req.ctx) {
            req.ctx = (0, context_1.newContext)();
        }
        const log = (0, logger_1.newLogger)({
            service: service,
            level: process.env[types_1.LOGGER_LEVEL_ENV],
            tracingId: (0, tracing_1.getTracing)(req.ctx),
        });
        req.ctx = (0, context_2.withLogger)(req.ctx, log);
        next();
    };
};
exports.expressLogger = expressLogger;
//# sourceMappingURL=middleware.js.map