Skip to content
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

Docs: Logger - Cloning Logger config to all other registered standard loggers example has errors #1215

Closed
michaelbrewer opened this issue May 18, 2022 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@michaelbrewer
Copy link
Contributor

michaelbrewer commented May 18, 2022

Expected Behaviour

Cloning Logger config to all other registered standard loggers - example in FAQ should not have any errors

Current Behaviour

Running the provided snippet results in the following error

Screen Shot 2022-05-17 at 8 38 16 PM

Code snippet

import logging

from aws_lambda_powertools import Logger
from aws_lambda_powertools.logging import utils

logger = Logger()

external_logger = logging.logger()

utils.copy_config_to_registered_loggers(source_logger=logger)
external_logger.info("test message")

Possible Solution

Use the correct method getLogger and the code will run, see PR #1121 for a fix and visit https://gyft.github.io/aws-lambda-powertools-python/latest/core/logger/#faq for a deployed version of the docs

import logging

from aws_lambda_powertools import Logger
from aws_lambda_powertools.logging import utils

logger = Logger()

external_logger = logging.getLogger(name="example")

utils.copy_config_to_registered_loggers(source_logger=logger)
external_logger.info("test message")

Now the output is:

{"level":"INFO","location":"<module>:11","message":"test message","timestamp":"2022-05-17 20:41:19,810-0700","service":"service_undefined"}

Steps to Reproduce

  1. Go to https://awslabs.github.io/aws-lambda-powertools-python/latest/core/logger/#faq
  2. Copy code example for Cloning Logger config to all other registered standard loggers
  3. Run the example code

AWS Lambda Powertools for Python version

latest

AWS Lambda function runtime

3.9

Packaging format used

PyPi

Debugging logs

N/A
@michaelbrewer michaelbrewer added bug Something isn't working triage Pending triage from maintainers labels May 18, 2022
@michaelbrewer michaelbrewer changed the title Bug: Logger, Cloning Logger config to all other registered standard loggers example has errors Bug: Logger - Cloning Logger config to all other registered standard loggers example has errors May 18, 2022
@sthulb sthulb changed the title Bug: Logger - Cloning Logger config to all other registered standard loggers example has errors Docs: Logger - Cloning Logger config to all other registered standard loggers example has errors May 18, 2022
@heitorlessa heitorlessa added documentation Improvements or additions to documentation and removed bug Something isn't working labels May 20, 2022
@sthulb sthulb closed this as completed Jun 14, 2022
@github-actions
Copy link
Contributor

Comments on closed issues are hard for our team to see.

@heitorlessa heitorlessa removed the triage Pending triage from maintainers label Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants