You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
native logger integration / dep loglevel config? #649
Python comes with some logging niceties built-in, among which the ability to use yaml-based configuration for logging. this facilitates e.g. the configuration of logging levels of dependencies.
this sounds nice, but i'm not sure how to achieve something similar with powertools's logger. is this something that is currently possible, or might this be desirable as a potential enhancement?
Child loggers (Logger(child=true)) have bi-directional sync, which means if you change the logger it'll replicate both ways, for example if you add a new key: logger.append_keys(payment_id="123")
We don't plan to add a YAML based config as you don't need to configure it like you do the traditional logger, you simply do logger = Logger(), and it just works. You can opt-in for other features like setting correlation ID, log sampling, but you'd want to do this conditionally, not statically.
Does that help?
I'm more than happy to clarify any questions you might have.
hi,
this issue i'm concerned about is about dependencies.
i know that for my own code i can control which logging level of messages will be printed.
the issue is, i'm consuming other pip packages that log things as well, and in some cases turn out buggy.
in such cases, i would like to be able to print debug-level info for such a broken package.
that is something that by default python logging can achieve. however, as i currently understand it, since the powertools logging library does not hook into this built-in way of logging, it lacks that functionality.
is this understanding correct?
Ah! I totally misunderstood, sorry.
You can get the namespace logger and set the level as you normally would
with any logging that used std logging[1].
Could you share the workflow you have in mind so I can share a snippet with
you?
I don’t wanna assume you want to propagate down, upwards, or in another way
I might not be thinking.
-----------
Edited to add an initial snippet in case it's helpful.
[1] Creating a Logger named `booking` and setting their log level to DEBUG elsewhere in the code
```python
# app.py
from aws_lambda_powertools import Logger
logger = Logger(service="booking")
# somewhere in the code
import logging
booking_logger = logging.getLogger("booking") # we name the logger using service name value
booking_logger.setLevel("DEBUG")
```
On Mon, 27 Sep 2021 at 17:08, Kiara Grouwstra ***@***.***> wrote:
hi,
this issue i'm concerned about is about dependencies.
i know that for my own code i can control which logging level of messages
will be printed.
the issue is, i'm consuming other pip packages that log things as well,
and in some cases turn out buggy.
in such cases, i would like to be able to print debug-level info for such
a broken package.
that is something that by default python logging can achieve. however, as
i currently understand it, since the powertools logging library does not
hook into this built-in way of logging, it lacks that functionality.
is this understanding correct?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#649 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZPQBDWTQS6CVZBDXQSFNDUECCHDANCNFSM5CWMENMQ>
.
hi there,
i'm not sure i fully understood the proposed solution.
i wanna use this library for logging, while a buggy dependency of mine is not aware of the existence of this library. moreover, given this is an external library i'm consuming, i do not have direct control over the code it uses.
if i use native logging for my own application, i can configure the logging level for my buggy dependency using config files.
what would be the equivalent when for my own application i wish to log using aws-lambda-powertools?
Activity
boring-cyborg commentedon Aug 24, 2021
Thanks for opening your first issue here! We'll come back to you as soon as we can.
heitorlessa commentedon Sep 27, 2021
hey @KiaraGrouwstra thank you for creating it - apologies for the delay, just got back from a long vacation.
For setting the log level, you can use either
Logger(level="DEBUG")or simply the environment variableLOG_LEVELas per our docs: https://awslabs.github.io/aws-lambda-powertools-python/latest/core/logger/#getting-startedChild loggers (
Logger(child=true)) have bi-directional sync, which means if you change the logger it'll replicate both ways, for example if you add a new key:logger.append_keys(payment_id="123")We don't plan to add a YAML based config as you don't need to configure it like you do the traditional logger, you simply do
logger = Logger(), and it just works. You can opt-in for other features like setting correlation ID, log sampling, but you'd want to do this conditionally, not statically.Does that help?
I'm more than happy to clarify any questions you might have.
KiaraGrouwstra commentedon Sep 27, 2021
hi,
this issue i'm concerned about is about dependencies.
i know that for my own code i can control which logging level of messages will be printed.
the issue is, i'm consuming other pip packages that log things as well, and in some cases turn out buggy.
in such cases, i would like to be able to print debug-level info for such a broken package.
that is something that by default python logging can achieve. however, as i currently understand it, since the powertools logging library does not hook into this built-in way of logging, it lacks that functionality.
is this understanding correct?
heitorlessa commentedon Sep 27, 2021
heitorlessa commentedon Oct 5, 2021
Checking in to see if this helped, and whether we could have more details on the issue report about the workflow to address this properly
KiaraGrouwstra commentedon Oct 20, 2021
hi there,
i'm not sure i fully understood the proposed solution.
i wanna use this library for logging, while a buggy dependency of mine is not aware of the existence of this library. moreover, given this is an external library i'm consuming, i do not have direct control over the code it uses.
if i use native logging for my own application, i can configure the logging level for my buggy dependency using config files.
what would be the equivalent when for my own application i wish to log using
aws-lambda-powertools?