'use strict'; var logger = require('@mastra/core/logger'); var pino = require('pino'); var pretty = require('pino-pretty'); function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } var pino__default = /*#__PURE__*/_interopDefault(pino); var pretty__default = /*#__PURE__*/_interopDefault(pretty); // src/pino.ts var PinoLogger = class _PinoLogger extends logger.MastraLogger { logger; constructor(options = {}) { super(options); const internalOptions = options; if (internalOptions._logger) { this.logger = internalOptions._logger; return; } const shouldPrettyPrint = options.prettyPrint ?? true; let prettyStream = void 0; if (!options.overrideDefaultTransports && shouldPrettyPrint) { prettyStream = pretty__default.default({ colorize: true, levelFirst: true, ignore: "pid,hostname,component", colorizeObjects: true, translateTime: "SYS:standard", singleLine: false }); } const transportsAry = [...this.getTransports().entries()]; this.logger = pino__default.default( { name: options.name || "app", level: options.level || logger.LogLevel.INFO, formatters: options.formatters, redact: options.redact, mixin: options.mixin, customLevels: options.customLevels, messageKey: options.messageKey ?? "msg" }, options.overrideDefaultTransports ? options?.transports?.default : transportsAry.length === 0 ? prettyStream : pino__default.default.multistream([ ...transportsAry.map(([, transport]) => ({ stream: transport, level: options.level || logger.LogLevel.INFO })), ...prettyStream ? [{ stream: prettyStream, level: options.level || logger.LogLevel.INFO }] : [] ]) ); } /** * Creates a child logger with additional bound context. * All logs from the child logger will include the bound context. * * @param bindings - Key-value pairs to include in all logs from this child logger * @returns A new PinoLogger instance with the bound context * * @example * ```typescript * const baseLogger = new PinoLogger({ name: 'MyApp' }); * * // Create module-scoped logger * const serviceLogger = baseLogger.child({ module: 'UserService' }); * serviceLogger.info('User created', { userId: '123' }); * // Output includes: { module: 'UserService', userId: '123', msg: 'User created' } * * // Create request-scoped logger * const requestLogger = baseLogger.child({ requestId: req.id }); * requestLogger.error('Request failed', { err: error }); * // Output includes: { requestId: 'abc', msg: 'Request failed', err: {...} } * ``` */ child(bindings) { const childPino = this.logger.child(bindings); const childOptions = { name: this.name, level: this.level, transports: Object.fromEntries(this.transports), _logger: childPino }; return new _PinoLogger(childOptions); } debug(message, args = {}) { this.logger.debug(args, message); } info(message, args = {}) { this.logger.info(args, message); } warn(message, args = {}) { this.logger.warn(args, message); } error(message, args = {}) { this.logger.error(args, message); } }; exports.PinoLogger = PinoLogger; //# sourceMappingURL=index.cjs.map //# sourceMappingURL=index.cjs.map