UNPKG

fixparser-plugin-log-console

Version:

Console / JSON logger for FIXParser

51 lines (50 loc) 1.29 kB
// src/ConsoleLogTransport.ts var ConsoleLogTransport = class { format; constructor({ format = "json" }) { this.format = format; } /** * Configures the format for console logging (either 'console' for text or 'json'). */ configure(config) { this.format = config.format || "json"; } /** * Sends the log message to the console in the configured format. */ async send(log) { if (this.format === "json") { console.log(JSON.stringify(log)); } else { const { name, id, message, level, ...additionalProperties } = log; const kv = Object.entries(additionalProperties).map(([key, value]) => `${key}: ${value}`); let logMessage = ""; if (name) { logMessage += `${name} `; } logMessage += `${id}: ${message}`; console.log(logMessage, kv.join(", ")); } } /** * Flushes the log buffer (if any buffering mechanism exists). */ async flush() { } /** * Closes the transport (not needed for console, but keeping the method for consistency). */ async close() { } /** * Returns the status of the transport (always "connected" for console). */ status() { return "connected"; } }; export { ConsoleLogTransport }; //# sourceMappingURL=ConsoleLogTransport.mjs.map