Skip to content

Feature request: Log warning message if Advanced Logging Controls log level is less verbose than Logger level #3821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
tknisch opened this issue Apr 10, 2025 · 12 comments · Fixed by #3834
Closed
2 tasks done
Assignees
Labels
feature-request This item refers to a feature request for an existing or new utility logger This item relates to the Logger Utility pending-release This item has been merged and will be released soon

Comments

@tknisch
Copy link

tknisch commented Apr 10, 2025

Use case

If I use the Logger for example at Debug level and the Advanced Logging Controls are set to Info I will not get the log messages printed.
It would be nice, the a warning message could be printed if this constellation is given.

Solution/User Experience

Print a warning message (configurable) if log messages would be suppressed by Advanced Logging Controls.

Alternative solutions

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

@tknisch tknisch added feature-request This item refers to a feature request for an existing or new utility triage This item has not been triaged by a maintainer, please wait labels Apr 10, 2025
Copy link

boring-cyborg bot commented Apr 10, 2025

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

@dreamorosi dreamorosi added logger This item relates to the Logger Utility confirmed The scope is clear, ready for implementation and removed triage This item has not been triaged by a maintainer, please wait labels Apr 10, 2025
@dreamorosi dreamorosi moved this from Triage to Backlog in Powertools for AWS Lambda (TypeScript) Apr 10, 2025
@dreamorosi
Copy link
Contributor

Hi @tknisch, thank you for opening this issue.

As we discussed on Discord, I think this is something we missed and should address.

We already have a way to detect whether Advanced Logging Controls is enabled and its level, so I think with some light refactoring we should be able to check that value and emit a warning if the log level is less verbose and log buffering is enabled.

We should also add a callout to the docs as additional measure.

Thank you for bringing this up!

@dreamorosi dreamorosi added the help-wanted We would really appreciate some support from community for this one label Apr 10, 2025
@dreamorosi
Copy link
Contributor

I've added the help-wanted label, so if anyone is interested in contributing please leave a comment and I'll assign the issue to you.

In terms of implementation, I think we should add some logic around here and call this.getEnvVarsService().getAwsLogLevel();. If the value of that variable is less verbose than the log buffering threshold, then we should call this.warnOnce() and let the customer know.

@ConnorKirk
Copy link
Contributor

I can take a look

@dreamorosi
Copy link
Contributor

Thank you @ConnorKirk - let me know if you need any help.

Ideally I'd like to include the change in the next release (~22/04), if plans change on your side let me know and we'll take over.

@leandrodamascena
Copy link
Contributor

Hi, @dreamorosi. @anafalcao is working on this implementation in Python, just to make sure the idea of ​​the implementation here is clear.

We already issue a warning if the Powertools LogLevel is more verbose than ALC and this works as expected. But now we need to issue a new warning when the customer flushes the buffer so that the customer knows that the flush_buffer will have no effect.

If the idea is to enable based on the buffer level log I think we need to review this. I think it makes more sense when flushing, since that is where the data loss will occur.

WDYT?

@dreamorosi
Copy link
Contributor

dreamorosi commented Apr 10, 2025

Imo we should just log a warning when you initialize the logger and these conditions happen:

  • you enable log buffering
  • the ALC log level is less verbose than log buffering

So for example if you set ALC to INFO (like this customer did) and enable buffering by default, you'd immediately get a warning telling you that you'll 100% lose data with this config, since whatever is buffered is automatically lost.

If we logged the warning upon flushing, you would never find out until you've lost the data.

It we log on init, you've got a chance to fix before the data is actually lost.

This is in line with the other init warning we emit when you set ALC less verbose than your log level. Since ALC is an env config, it makes sense to warn the customer as soon as we detect it.

@tknisch
Copy link
Author

tknisch commented Apr 11, 2025

If we log on init, you've got a chance to fix before the data is actually lost.

From a customer perspective I would prefer this also.

If, for example I test my code on lower stages where the ALC is set to DEBUG I will not run into the problem.
Then I deploy to production where the ALC is set to INFO or above.
When the warning will be printed in error case first, we will miss logs.
But when it will be printed at initiation we will see this

@dreamorosi
Copy link
Contributor

Had a quick chat with @leandrodamascena offline and he brought forward a good point.

The TL;DR; is that we should emit a warning once, both:

  • when instantiating a new Logger instance
  • when flushing the log buffer

The first one covers early detection, but the second one covers the actual moment of the data loss.

If we emitted the warning only during init, there's a non-zero chance that the warning could go unnoticed if the buffer is flushed at a much later point.

Because of this, we'll emit a warning in both cases.

Thank you @leandrodamascena.

@leandrodamascena
Copy link
Contributor

Hey @anafalcao, please check this issue.

@anafalcao
Copy link

Thanks guys! It makes sense. I'll submit a PR this week for Python based on that.

@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in Powertools for AWS Lambda (TypeScript) Apr 16, 2025
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot removed help-wanted We would really appreciate some support from community for this one confirmed The scope is clear, ready for implementation labels Apr 16, 2025
@github-actions github-actions bot added the pending-release This item has been merged and will be released soon label Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request This item refers to a feature request for an existing or new utility logger This item relates to the Logger Utility pending-release This item has been merged and will be released soon
Projects
Status: Coming soon
5 participants