Skip to content

env var to set loglevel for python logging #41

Open
@barakbd

Description

@barakbd

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.

Activity

ghost

ghost commented on Aug 10, 2022

@ghost

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 added
enhancementNew feature or request
on Aug 17, 2022
ghost added
questionFurther information is requested
on Aug 17, 2022
ghost

ghost commented on Aug 29, 2022

@ghost

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 added
resolved-upstreamThis is resolved in AWS's upstream repository and will be closed on the next merge
on Aug 29, 2022
ghost removed
questionFurther information is requested
on Aug 29, 2022
jcampbell05

jcampbell05 commented on Nov 14, 2022

@jcampbell05

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

ghost commented on Nov 14, 2022

@ghost

@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

jcampbell05 commented on Nov 14, 2022

@jcampbell05

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

ghost commented on Nov 14, 2022

@ghost

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

jcampbell05 commented on Nov 16, 2022

@jcampbell05

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

jcampbell05 commented on Nov 17, 2022

@jcampbell05

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestresolved-upstreamThis is resolved in AWS's upstream repository and will be closed on the next merge

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jcampbell05@barakbd

        Issue actions

          env var to set loglevel for python logging · Issue #41 · aws/aws-lambda-runtime-interface-emulator