Closed
Description
What were you trying to accomplish?
Re-use a logger in a sub-module, using the child=True
feature, per the documentation.
Expected Behavior
With the following setup, there should be two log entries, one with "service": "foo"
and one with "service": "foo.bar"
.
cat foo.py
:
$ cat foo.py
import aws_lambda_powertools
import bar
log = aws_lambda_powertools.Logger(service="foo")
log.info('hallelujah')
bar.bar()
cat bar.py
:
import aws_lambda_powertools
log = aws_lambda_powertools.Logger(child=True)
def bar():
log.info('doublestuff')
Current Behavior
$ python foo.py
{"timestamp": "2020-08-27 11:20:16,245", "level": "INFO", "location": "<module>:6", "service": "foo", "sampling_rate": 0.0, "message": "hallelujah"}
Even setting the service
explicitly in the submodule to foo.bar
, the service remains foo
in the output, though at least now their are two log entries.
cat bar.py
:
$ cat bar.py
import aws_lambda_powertools
log = aws_lambda_powertools.Logger(service="foo.bar", child=True)
def bar():
log.info('doublestuff')
$ python foo.py
{"timestamp": "2020-08-27 11:26:05,330", "level": "INFO", "location": "<module>:6", "service": "foo", "sampling_rate": 0.0, "message": "hallelujah"}
{"timestamp": "2020-08-27 11:26:05,330", "level": "INFO", "location": "bar:6", "service": "foo", "sampling_rate": 0.0, "message": "doublestuff"}
Steps to Reproduce (for bugs)
See above.
Environment
- Powertools version used: 1.4.0
- Packaging format (Layers, PyPi): PyPi
- AWS Lambda function runtime: running locally, not in lambda yet
Metadata
Metadata
Assignees
Type
Projects
Status
Triage