Skip to content

Bug: programmatically changing the log level fails #2303

Closed

Description

@paulsuh

Expected Behaviour

When changing the log level of a Logger via code, the log level should be changed.

from aws_lambda_powertools import Logger
powertools_logger = Logger()
powertools_logger.setLevel("DEBUG")    # the log level should become DEBUG
powertools_logger.debug("Hello, world!")    # this should produce a log message

Current Behaviour

When changing the log level of a Logger via code, the log level is not changed.

from aws_lambda_powertools import Logger
powertools_logger = Logger()
powertools_logger.setLevel("DEBUG")    # the log level remains at the default, INFO
powertools_logger.debug("Hello, world!")    # no log message comes out

Code snippet

See above, also the linked repo below

Possible Solution

No response

Steps to Reproduce

See https://github.com/paulsuh/aws-powertools-logging-test-sam for detailed test cases and output.

AWS Lambda Powertools for Python version

latest

AWS Lambda function runtime

3.9

Packaging format used

Serverless Application Repository (SAR) App

Debugging logs

No response

Activity

  1. added
    bug
    triage
    on May 22, 2023
  2. boring-cyborg commented on May 22, 2023

    @boring-cyborg

    Thanks for opening your first issue here! We'll come back to you as soon as we can.
    In the meantime, check out the #python channel on our AWS Lambda Powertools Discord: Invite link

  3. heitorlessa commented on May 22, 2023

    @heitorlessa
    Contributor
  4. leandrodamascena commented on May 22, 2023

    @leandrodamascena
    Contributor

    Hi @heitorlessa and @paulsuh! I could reproduce the error and it's changing the superclass logging.Logger instead of changing the Powertools instance: ._logger in this case.

    Paul, do you want to send a PR to fix this and get your first contribution to Powertools? If not, I can send the PR to fix this and give you the credits.

    Thank you

  5. added and removed
    triage
    on May 22, 2023
  6. paulsuh commented on May 22, 2023

    @paulsuh
    Author

    Let me clone the repo and see what I can do

  7. leandrodamascena commented on May 23, 2023

    @leandrodamascena
    Contributor

    Hello @paulsuh! Can I help you write this fix? We are planning to release a new version today or tomorrow and it would be nice if we could include this fix.
    No pressure here, we know everyone is busy with different things at work, I'm really here to offer help or even just write this and discuss the solution together when sending the PR.

    Thank you so much!

  8. github-actions commented on May 24, 2023

    @github-actions
    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.

  9. added
    pending-release
    on May 24, 2023
  10. github-actions commented on Jun 2, 2023

    @github-actions
    Contributor

    This is now released under 2.16.1 version!

  11. removed
    pending-release
    on Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

buglogger

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions