@sotatech/nest-quickfix
Version:
A powerful NestJS implementation of the FIX (Financial Information eXchange) protocol. Provides high-performance, reliable messaging for financial trading applications with built-in session management, message validation, and recovery mechanisms.
46 lines • 1.64 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FIXLogger = void 0;
const winston = require("winston");
class FIXLogger {
static initialize(options) {
const transports = [];
if (options.console) {
transports.push(new winston.transports.Console({
format: winston.format.combine(winston.format.timestamp(), winston.format.colorize(), winston.format.printf(({ timestamp, level, message, ...meta }) => {
return `${timestamp} [${level}]: ${message} ${Object.keys(meta).length ? JSON.stringify(meta) : ''}`;
}))
}));
}
if (options.filename) {
transports.push(new winston.transports.File({
filename: options.filename,
format: winston.format.combine(winston.format.timestamp(), winston.format.json())
}));
}
this.logger = winston.createLogger({
level: options.level,
transports
});
}
static log(level, message, meta) {
if (!this.logger) {
this.initialize({ level: 'info', console: true });
}
this.logger.log(level, message, meta);
}
static error(message, error) {
this.log('error', message, { error: error?.stack });
}
static warn(message, meta) {
this.log('warn', message, meta);
}
static info(message, meta) {
this.log('info', message, meta);
}
static debug(message, meta) {
this.log('debug', message, meta);
}
}
exports.FIXLogger = FIXLogger;
//# sourceMappingURL=logger.js.map