UNPKG

pino-splunk-events

Version:
28 lines (23 loc) 735 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPinoWriteLog = void 0; var _toSplunkEvent = require("./toSplunkEvent"); const getPinoWriteLog = (splunk, { onSplunkLog = () => {} } = {}) => { const log = chunk => { if ((0, _toSplunkEvent.isSplunkLog)(chunk)) { onSplunkLog(chunk); const event = (0, _toSplunkEvent.toSplunkEvent)(chunk); splunk.logEvent(event.severity.level, event.severity.type, event.workflow.type, event.workflow.instance, event.data, event.account); } else { splunk.logEvent('Important', 'Warn', 'fallback-log', 'invalid-pino-log', { msg: chunk }); } }; return log; }; exports.getPinoWriteLog = getPinoWriteLog;