import { newContext } from "../context/context";
import { newLogger } from "./logger";
import { getTracing } from "../tracing";
import { withLogger } from "./context";
import { LOGGER_LEVEL_ENV } from "./types";
export const expressLogger = (service) => {
    return (req, response, next) => {
        if (!req.ctx) {
            req.ctx = newContext();
        }
        const log = newLogger({
            service: service,
            level: process.env[LOGGER_LEVEL_ENV],
            tracingId: getTracing(req.ctx),
        });
        req.ctx = withLogger(req.ctx, log);
        next();
    };
};
//# sourceMappingURL=middleware.js.map