feat(logging): replace 207 console.log/error/warn with pino structured logger (#58)

- Add pino + pino-pretty dependencies
- Create src/utils/logger.js with env-based LOG_LEVEL
- Replace all 207 console.log/error/warn calls across 46 source files
- Remove [DEBUG], [ERROR] string prefixes (levels convey this)
- Add pino redact for sensitive fields (mnemonic, privateKey, token, etc.)
- Structured logging with context objects instead of string interpolation
- NODE_ENV=production disables pino-pretty transport

49 files changed, 5601 insertions, 6056 deletions
This commit is contained in:
NW
2026-06-22 01:42:47 +01:00
parent ba80784ae7
commit ce1b6003cb
49 changed files with 5624 additions and 6079 deletions

View File

@@ -1,3 +1,5 @@
import logger from '../utils/logger.js';
class CallbackRouter {
constructor() {
this.exactRoutes = new Map();
@@ -29,7 +31,7 @@ class CallbackRouter {
}
}
console.warn(`No handler for callback: ${action}`);
logger.warn({ action }, 'No handler for callback');
}
}

View File

@@ -1,6 +1,7 @@
import callbackRouter from './callbackRouter.js';
import messageRouter from './messageRouter.js';
import { isAdmin } from '../middleware/auth.js';
import logger from '../utils/logger.js';
import userHandler from '../handlers/userHandlers/userHandler.js';
import userPurchaseHandler from '../handlers/userHandlers/userPurchaseHandler.js';
@@ -17,8 +18,7 @@ import adminWalletsHandler from '../handlers/adminHandlers/adminWalletsHandler.j
import adminUserHandler from '../handlers/adminHandlers/adminUserHandler.js';
const logDebug = (action, functionName) => {
console.log(`[DEBUG] Button Press: ${action}`);
console.log(`[DEBUG] Calling Function: ${functionName}`);
logger.debug({ action, functionName }, 'Button Press');
};
export function registerRoutes() {