native logger integration / dep loglevel config? #819
-
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. |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 2 replies
-
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Beta Was this translation helpful? Give feedback.
-
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 Child loggers ( 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 Does that help? I'm more than happy to clarify any questions you might have. |
Beta Was this translation helpful? Give feedback.
-
hi, |
Beta Was this translation helpful? Give feedback.
-
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>
.
|
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
hi there, |
Beta Was this translation helpful? Give feedback.
-
Hey Kiara - I’m not sure whether it helps on your use case but I’m gonna
add a new method in Logger to copy its configuration like formatting, JSON,
log level to all loggers in an application.
This could help in situations where you want other libraries - e.g. boto3 -
to use the same Log Level & output consistently.
When you have a chance, I’d love to see what the workflow you have in mind
for your problem since I haven’t used file-based configuration much before.
About the new feature
#799 (comment)
…On Sat, 13 Nov 2021 at 18:27, Kiara Grouwstra ***@***.***> wrote:
that sounds good, I'll try -- thank you!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#819 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZPQBHQY36TSKXRBITHQHLUL2NWZANCNFSM5H63CGAQ>
.
|
Beta Was this translation helpful? Give feedback.
-
Hey Kiara - We finally have this as a standalone function now (1.24.1) - please do let us know if this helps out. You can also explicitly configure which logger you want to copy Powertools Logger config to, and also set a different Log Level if you want to -- Omitting these will copy Logger structured config to all imported loggers. Release 1.24.1: https://github.com/awslabs/aws-lambda-powertools-python/releases/tag/v1.24.1 |
Beta Was this translation helpful? Give feedback.
Hey Kiara - We finally have this as a standalone function now (1.24.1) - please do let us know if this helps out. You can also explicitly configure which logger you want to copy Powertools Logger config to, and also set a different Log Level if you want to -- Omitting these will copy Logger structured config to all imported loggers.
Release 1.24.1: https://github.com/awslabs/aws-lambda-powertools-python/releases/tag/v1.24.1