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

env var to set loglevel for python logging #41

Open
barakbd opened this issue Jul 16, 2021 · 8 comments
Open

env var to set loglevel for python logging #41

barakbd opened this issue Jul 16, 2021 · 8 comments
Labels
enhancement New feature or request resolved-upstream This is resolved in AWS's upstream repository and will be closed on the next merge

Comments

@barakbd
Copy link

barakbd commented Jul 16, 2021

Is there a way to set the loglevel through an env var?
This would be especially useful for lambda-docker.
We would like to be able to filter out a lot of noise and only see our app logs, at least during development.

@ghost
Copy link

ghost commented Aug 10, 2022

Thank you for the suggestion barakbd.

It seems the default log level environment variable name in Go is LOG_LEVEL, is that what you would expect?

@ghost ghost added enhancement New feature or request question Further information is requested labels Aug 17, 2022
@ghost
Copy link

ghost commented Aug 29, 2022

Thank you @barakbd for this suggestion.

We have merged functionality upstream to enable the providing of the log level via the environment variable LOG_LEVEL.

This functionality will be available with the next merge from upstream. I will leave this ticket open until the next merge from upstream.

Thanks you!

@ghost ghost added resolved-upstream This is resolved in AWS's upstream repository and will be closed on the next merge and removed question Further information is requested labels Aug 29, 2022
@jcampbell05
Copy link

Has this been merge, I'm trying to debug why the RIE exits with a 0 code but I'm currently getting no logs to explain why.

LOG_LEVEL=DEBUG

Has no effect

@ghost
Copy link

ghost commented Nov 14, 2022

@jcampbell05 Sorry for the confusion.

No this functionality is not currently within this open sourced code base. This is why I have left the ticket open.

This has been merged into the upstream repository within Amazon and the functionality will be made available upon the next synchronisation from Amazon's upstream repository.

How are running your Lambda locally?

@jcampbell05
Copy link

We are currently using a Custom Container Image built on the Docker Hub Node image and followed the instructions in the documentation to download the emulator, install the Node runtime and run a ./entry.sh script

The runtime is working but currently the emulator exits immediately with a code 0 which from the code looks like what it does whenever it needs to shutdown but it currently fails to log any contextual information on why it's shutting down.

@ghost
Copy link

ghost commented Nov 14, 2022

You can modify the entry.sh script to pass the log level as a command line argument, while waiting on being able to pass it as an environment variable to be synchronised.

E.g.

#!/bin/sh

if [ -z "${AWS_LAMBDA_RUNTIME_API}" ]; then 
    exec /usr/local/bin/aws-lambda-rie /usr/bin/npx aws-lambda-ric --log-level "trace"
else 
    exec /usr/bin/npx aws-lambda-ric
fi

You can see this is something AWS SAM would do on your behalf[1] if you were using it.

@jcampbell05
Copy link

So I've added that flag and unfortunately it still just exits with a code 0 with no logs at all. I'll check out SAM but we already have an existing setup based around the serverless framework

@jcampbell05
Copy link

In the end it turns out I was forgetting to tell curl to follow redirects and it was downloading an empty binary which in turn was being executed without any errors by the container instead of a invalid format error as I assume it was being treated as an empty executable shell script.

More details here:
nodejs/docker-node#1812

But please disregard my earlier comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request resolved-upstream This is resolved in AWS's upstream repository and will be closed on the next merge
Projects
None yet
Development

No branches or pull requests

2 participants