elastic / ecs-logging-python

https://pypi.org/project/ecs-logging
Apache License 2.0
69 stars 25 forks source link

Add a context manager for temporarily adding extras to StdlibLogger #14

Open sethmlarson opened 4 years ago

sethmlarson commented 4 years ago

Similar to how structlog provides .bind() we could provide a context manager that adds extras so you don't have to include them every time you call .info(), etc.

Divyadarshee commented 3 years ago

@sethmlarson what is the current way to add extra without including them in every log call?

Divyadarshee commented 3 years ago

@sethmlarson can something like this be possible with the current version log example: addItem='abcd' logger.info(f"added todo item {addItem} to the todo list") log: {'name': 'app.routes.controller', 'msg': 'added todo item abcd to the todo list', 'args': (), 'levelname': 'INFO', 'levelno': 20, 'fields': {'addItem': 'abcd'}}