Skip to content
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

Pass params into logger.{info,debug} #913

Merged
merged 3 commits into from Jan 30, 2023

Conversation

richardm-stripe
Copy link
Contributor

Summary

Causes util.log_info and util.log_debug to pass more information into the underlying python logger.info and logger.debug methods.

By default, this will do nothing, but if you define and attach your own logger.Formatter you will be able to access this information on .args property on the argument to the format method.

class CoolFormatter(logging.Formatter):
    def format(self, record):
        # Just a proof of concept. This won't handle "bytes" nicely.
        return json.dumps(record.args)

Fixes #776.

@richardm-stripe
Copy link
Contributor Author

Closing this until we are able to get some user feedback, (maybe on #776). We think this solves this use case, but we want to be sure.

@neilpanchal
Copy link

This LGTM.

@richardm-stripe richardm-stripe enabled auto-merge (squash) January 30, 2023 19:56
@richardm-stripe richardm-stripe merged commit c45cc1d into master Jan 30, 2023
@richardm-stripe richardm-stripe deleted the richardm-extensible-logger branch January 30, 2023 19:58
@asherf
Copy link

asherf commented Feb 6, 2023

this change probably causes #922

richardm-stripe added a commit that referenced this pull request Feb 6, 2023
richardm-stripe added a commit that referenced this pull request Feb 6, 2023
richardm-stripe added a commit that referenced this pull request Feb 24, 2023
* Pass params into logger.{info,debug} (#913)

* Pass params into logger.{info,debug}

* API Updates (#920)

* Codegen for openapi v223

* Bump version to 5.1.0

* Revert "Pass params into logger.{info,debug} (#913)" (#923)

This reverts commit c45cc1d.

* Bump version to 5.1.1

* Codegen for openapi v225

* Bump version to 5.2.0

* Set version to 5.2.0 to simplify merge

* Reset version to 5.2.0b1

* Codegen for openapi v232

* Format

---------

Co-authored-by: Annie Li <anniel@stripe.com>
Co-authored-by: anniel-stripe <97691964+anniel-stripe@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSON log formatting
4 participants