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,13 +1,14 @@
import TelegramBot from "node-telegram-bot-api";
import config from "../config/config.js";
import logger from "../utils/logger.js";
const initBot = () => {
try {
const bot = new TelegramBot(config.BOT_TOKEN, {polling: true});
console.log('Bot initialized successfully');
logger.info('Bot initialized successfully');
return bot;
} catch (error) {
console.error('Failed to initialize bot:', error);
logger.error({ err: error }, 'Failed to initialize bot');
process.exit(1);
}
};