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

Improv: Separate module logger from code logger #16

Closed
7 tasks
heitorlessa opened this issue Apr 9, 2020 · 6 comments
Closed
7 tasks

Improv: Separate module logger from code logger #16

heitorlessa opened this issue Apr 9, 2020 · 6 comments
Assignees

Comments

@heitorlessa
Copy link
Contributor

heitorlessa commented Apr 9, 2020

From discussion with @jfuss, it'd best to create a separate environment variable to control powertools logging level as opposed to LOG_LEVEL.

While LOG_LEVEL simplifies DX it does raise concerns if you want to isolate logging level to your Lambda function only.

Convo: aws-powertools/powertools-lambda#15 (comment)


Changes

  • Create a POWERTOOLS_LOG_LEVEL environment variable
  • Update all modules to use POWERTOOLS_LOG_LEVEL
  • Use a Null Handler to cut noise in customers' logging
  • Create top-level logger aws-lambda-powertools
  • Update docs to reflect the change
  • Accept an existing logger in logger setup
  • Refactor Lambda Logging module to prevent root logging changes
@heitorlessa
Copy link
Contributor Author

@heitorlessa heitorlessa changed the title Separate module logger from code logger Improv: Separate module logger from code logger Apr 14, 2020
@heitorlessa
Copy link
Contributor Author

Now available in 0.8.0

@marcioemiranda
Copy link

Hello Heitor,

Today I've tried the new logging package from the develop branch.

I've experienced a side effect in lambdas that also use the tracer functionality.

They started to show the following message:
Unable to import module 'xxxx/lambda_function': No module named 'aws_xray_sdk'

I didn't have to add any x-ray related module before.
I've just changed the way I import the logger module and used the logger class instead of the function.

If I remove the line where I import the tracer module, then this error goes away.

Some context:

  • I use python 3.6
  • aws lambda power tools is deployed in lambda layers.
  • I have a layer version with v0.8 and a couple of lambdas pointing to it and the rest of the app pointing to previous versions

Any thoughts?

@heitorlessa
Copy link
Contributor Author

heitorlessa commented Apr 27, 2020 via email

@heitorlessa
Copy link
Contributor Author

Hi Marcio - I've just tested by creating a layer from scratch and works just fine.

I've published the same testing layer in Sao Paulo region where you could test: arn:aws:lambda:sa-east-1:231436140809:layer:aws-lambda-powertools

Steps when trying to reproduce

# Using current version with the new Logger class
echo "aws-lambda-powertools==0.8.0" > requirements.txt

mkdir -p layer/python

# Build a Layer using Docker Lambda
docker run -v "$PWD":/var/task "lambci/lambda:build-python3.7" \
    /bin/sh -c "pip install -r requirements.txt -t layer/python/; exit"

# Create ZIP file
cd layer/ && zip -r ../layer.zip python/ > /dev/null && cd -

# Publish Layer
aws lambda publish-layer-version --layer-name aws-lambda-powertools \
    --description "Lambda Powertools 0.8.0" \
    --zip-file fileb://layer.zip \
    --compatible-runtimes "python3.6" "python3.7" "python3.8"

# Use "LayerVersionArn" output value in any existing or brand new function

@marcioemiranda
Copy link

marcioemiranda commented Apr 27, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants