Skip to content

Feature request: Silent mode for all testing environments #1198

Closed
@jamesmhaley

Description

@jamesmhaley

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

Metadata

Metadata

Assignees

Labels

completedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityloggerThis item relates to the Logger Utility

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions