Description
Use case
I'm a huge fan of the logger, thanks for all your hard work on it!! One side affect of it though is it can be super noisy when testing. It's useful to have the POWERTOOLS_DEV env variable, this is helpful. However, the problem with this is that there is no option of less noise, just silence.
I often debug with my IDE, but on occasion i'll add a console.log
and find it useful to see that output. With my previous favourite logger (winston) you could silence within tests and that would stop the winston logger from outputting when explicitly silenced.
Solution/User Experience
It would be great to be able to set the logger to silent when a certain condition is met, like in a test or dev environment. This could be using NODE_ENV
or another conditional.
A good solution would be to add an optional parameter of silent
to the logger on invocation:
const logger = new Logger({
silent: process.env.NODE_ENV === 'test',
serviceName: 'AWS-SERVICE',
persistentLogAttributes: {
awsRegion: process.env.AWS_REGION || 'N/A',
},
})
This would allow for console.log
to still make it's way through to the terminal, while reducing the noise from Logger.
Alternative solutions
No response
Acknowledgment
- This feature request meets Lambda Powertools Tenets
- Should this be considered in other Lambda Powertools languages? i.e. Python, Java