Closed amliuyong closed 1 year ago
Thanks for opening your first issue here! We'll come back to you as soon as we can. In the meantime, check out the #typescript channel on our Powertools for AWS Lambda Discord: Invite link
Hi @amliuyong thank you for opening the issue.
Could you please confirm how you are setting these variables:
const POWERTOOLS_ENVS = {
POWERTOOLS_SERVICE_NAME: 'ClickStreamAnalyticsOnAWS',
POWERTOOLS_LOGGER_SAMPLE_RATE: '1',
POWERTOOLS_LOGGER_LOG_EVENT: 'true',
LOG_LEVEL: 'WARN',
};
Based on the snippet you have shared it seems that they are in an object and that the constructor below (const logger = new Logger();
) has no argument.
In order to set the log level, you have three options:
LOG_LEVEL
as an environment variable in your function (this will depend on how you are deploying it)logLevel
property to the constructor (const logger = new Logger({ logLevel: "WARN"});
logger.setLogLevel('DEBUG');
)I have taken the liberty of creating a sample repo to try to reproduce the issue. I wasn't able to reproduce the behavior described as long as the log level is set via one of the three methods I described.
You can find the sample repo here: https://github.com/dreamorosi/repro-1626
If you'd like to try it, you can follow these steps:
npm ci
to install the dependenciesnpx cdk deploy
& follow the prompts to deploy the sampleThen invoke the three functions and check the logs, which should look like the ones in the image below:
This issue has not received a response in 2 weeks. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.
Greetings! We are closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or reopen the issue.
Expected Behaviour
set ENV of LOG_LEVEL = WARN in lambda function, only WARN or above should be printed, but INFO and DEBUG logs are printed.
Current Behaviour
set ENV of LOG_LEVEL = WARN in lambda function, only WARN or above should be printed, but INFO and DEBUG logs are printed.
Code snippet
Steps to Reproduce
Possible Solution
No response
Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
16.x
Packaging format used
npm
Execution logs