@nevuamarkets/poly-websockets
Version:
Plug-and-play Polymarket WebSocket price alerts
35 lines (34 loc) • 1.61 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.logger = void 0;
const winston_1 = __importDefault(require("winston"));
// Override with LOG_LEVEL environment variable (e.g., LOG_LEVEL=info npm start)
exports.logger = winston_1.default.createLogger({
level: process.env.LOG_LEVEL || 'warn',
format: winston_1.default.format.combine(winston_1.default.format.timestamp(), winston_1.default.format.errors({ stack: true }), winston_1.default.format.colorize(), winston_1.default.format.printf(({ level, message, timestamp, ...rest }) => {
// Ensure consistent order: timestamp, level, message, then rest of fields
const restString = Object.keys(rest)
.filter(key => key !== 'service') // Exclude service since we add it in defaultMeta
.sort()
.map(key => `${key}: ${JSON.stringify(rest[key])}`)
.join(', ');
return `${timestamp} ${level}: ${message}${restString ? ` (${restString})` : ''}`;
})),
defaultMeta: { service: 'poly-websockets' },
transports: [
new winston_1.default.transports.Console({
format: winston_1.default.format.combine(winston_1.default.format.colorize({
all: true,
colors: {
error: 'red',
warn: 'yellow',
info: 'cyan',
debug: 'green'
}
}))
})
]
});