From 155692f71d477d989b4b524e7740c16e826922a6 Mon Sep 17 00:00:00 2001 From: STEINNI Date: Fri, 26 Jun 2026 16:30:03 +0000 Subject: [PATCH] timestamps in logs, aligned with other daemons --- p42wssGateway.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/p42wssGateway.js b/p42wssGateway.js index 6cde716..0caaa74 100644 --- a/p42wssGateway.js +++ b/p42wssGateway.js @@ -10,6 +10,18 @@ import express from 'express' import session from 'express-session' import connectMySQL from 'express-mysql-session' +const originalLog = console.log +const originalWarn = console.warn +const originalError = console.error +function logWithTimestamp(originalFn, level, ...args) { + const timestamp = new Date().toISOString() + originalFn(`[${timestamp}] [${level}]`, ...args) +} + +console.log = (...args) => logWithTimestamp(originalLog, 'LOG', ...args) +console.warn = (...args) => logWithTimestamp(originalWarn, 'WARN', ...args) +console.error = (...args) => logWithTimestamp(originalError, 'ERROR', ...args) + const argv = yargs(hideBin(process.argv)).command('wssGateway', 'Redis <=> Websocket message bus gateway', {}) .options({ 'argv.debug': {