ecs-logging-python icon indicating copy to clipboard operation
ecs-logging-python copied to clipboard

Add a context manager for temporarily adding extras to StdlibLogger

Open sethmlarson opened this issue 5 years ago • 2 comments

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.

sethmlarson avatar Jul 22 '20 14:07 sethmlarson

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

Divyadarshee avatar Apr 22 '21 17:04 Divyadarshee

@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'}}

Divyadarshee avatar Apr 23 '21 05:04 Divyadarshee