-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: support json logs #316
Conversation
# add logger name as a label if possible | ||
logger_label = {"python_logger": record.name} if record.name else {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this done for telemetry purposes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly for backwards compatibility. Previously, all logs were json logs with a message
field for user input and python_logger
with the logger name as the other field.
I wanted to give users control over the entire payload so they could log arbitrary json objects, but I thought I should still put python_logger
as a label in case some users were relying on it
This PR adds full support for JSON logs, along with standard text logs. Now, users can call
logging.error({'a':'b'})
, and they will get a JsonPayload in Cloud Logging, Or calllogging.error('test')
to receive a TextPayloadAs part of this change, I added a generic
loger.log()
function, which serves as a generic entry-point instead oflogger.log_text
orlogger.log_struct
. It will infer which log function is meant based on the input typePreviously, the library would attach the python logger name as part of the JSON payload for each log. Now, that information will be attached as a label instead, giving users full control of the log payload fields
Fixes #186, #263, #13