Add StructuredLogHandler adapter #750
Labels
api: logging
Issues related to the googleapis/python-logging API.
priority: p3
Desirable enhancement or fix. May not be included in next release.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
Thanks for stopping by to let us know something could be better!
Is your feature request related to a problem? Please describe.
In my project hosted in Google Cloud, I use
StructuredLogHandler
and quite often I need to pass some predefined context to log labels for easier system monitoring.Let's say it could be some service configuration values, code versions, and many more.
Basically, I need to pass such context data every logger call:
logger.info('my message', extra={'labels': ...}}
which is hard to maintain.Describe the solution you'd like
For this case, we have
logging.LoggerAdapter
in the Python standard library.And I propose adding a specific adapter to support the Google Cloud format for this purpose.
I have implemented it already in my project, and think it could be useful for everyone.
With that adapter, I need to configure my logging context once and use my logger in an easier manner.
Let's look at the example:
The text was updated successfully, but these errors were encountered: