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:
19
src/utils/logger.js
Normal file
19
src/utils/logger.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import pino from 'pino';
|
||||
|
||||
const level = process.env.LOG_LEVEL || 'info';
|
||||
|
||||
const options = {
|
||||
level,
|
||||
redact: ['*.mnemonic', '*.privateKey', '*.secret', '*.token', '*.password', '*.ENCRYPTION_KEY', '*.BOT_TOKEN'],
|
||||
serializers: {
|
||||
err: pino.stdSerializers.err,
|
||||
},
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
options.transport = { target: 'pino-pretty', options: { colorize: true } };
|
||||
}
|
||||
|
||||
const logger = pino(options);
|
||||
|
||||
export default logger;
|
||||
Reference in New Issue
Block a user