'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var build = require('pino-abstract-transport'); var js = require('@axiomhq/js'); exports.AxiomEventLevel = void 0; (function (AxiomEventLevel) { AxiomEventLevel["Trace"] = "trace"; AxiomEventLevel["Debug"] = "debug"; AxiomEventLevel["Info"] = "info"; AxiomEventLevel["Warn"] = "warn"; AxiomEventLevel["Error"] = "error"; AxiomEventLevel["Fatal"] = "fatal"; AxiomEventLevel["Silent"] = "silent"; })(exports.AxiomEventLevel || (exports.AxiomEventLevel = {})); async function axiomTransport(options) { const axiom = new js.Axiom(options); const dataset = options.dataset; return build(async function (source) { for await (const obj of source) { const { time, level, ...rest } = obj; const event = { _time: time, level: mapLogLevel(level), ...rest, }; axiom.ingest(dataset, event); } }, { close: async () => await axiom.flush() }); } // See https://github.com/pinojs/pino/blob/master/docs/api.md#loggerlevel-string-gettersetter const mapLogLevel = (level) => { if (typeof level === 'string') { return level; } if (level <= 10) { return exports.AxiomEventLevel.Trace; } if (level <= 20) { return exports.AxiomEventLevel.Debug; } if (level <= 30) { return exports.AxiomEventLevel.Info; } if (level <= 40) { return exports.AxiomEventLevel.Warn; } if (level <= 50) { return exports.AxiomEventLevel.Error; } if (level <= 60) { return exports.AxiomEventLevel.Fatal; } return exports.AxiomEventLevel.Silent; }; exports.default = axiomTransport; exports.mapLogLevel = mapLogLevel; //# sourceMappingURL=index.cjs.map