"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/DataDogTransport.ts var _transport = require('@loglayer/transport'); var _datadogtransportcommon = require('datadog-transport-common'); var DataDogTransport = class extends _transport.LoggerlessTransport { constructor(config) { super(config); if (!this.enabled) { return; } this.transport = new (0, _datadogtransportcommon.DataDogTransport)(config.options); this.messageField = _nullishCoalesce(config.messageField, () => ( "message")); this.levelField = _nullishCoalesce(config.levelField, () => ( "level")); this.timestampField = _nullishCoalesce(config.timestampField, () => ( "time")); this.timestampFunction = config.timestampFunction; } shipToLogger({ logLevel, messages, data, hasData }) { const logEntry = {}; if (!this.transport) { throw new Error( "DataDogTransport was previously disabled; enabling the flag manually on the transport instance is not supported." ); } if (data && hasData) { Object.assign(logEntry, data); } if (this.timestampFunction) { logEntry[this.timestampField] = this.timestampFunction(); } else { logEntry[this.timestampField] = (/* @__PURE__ */ new Date()).toISOString(); } logEntry[this.levelField] = logLevel; logEntry[this.messageField] = messages.join(" "); this.transport.processLog(logEntry); return messages; } }; exports.DataDogTransport = DataDogTransport; //# sourceMappingURL=index.cjs.map