- 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
19 lines
468 B
JavaScript
19 lines
468 B
JavaScript
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; |