Skip to content

fix(logger): Support .info("foo %s", "bar") formatting #426

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

Merged
merged 1 commit into from
May 7, 2021

Conversation

huonw
Copy link
Contributor

@huonw huonw commented May 7, 2021

Issue #, if available: N/A

Description of changes:

This adjusts the default logging formatter (LambdaPowertoolsFormatter)
to handle non-structured logs with formatting, like:

logger.info("foo %s", "bar")

This allows the formatter to be used in more situations, such as the
universal formatter for all log messages coming out of a system, even
libraries using the normal logging functionality, without explicit
support for aws-lambda-powertools.

If formatting is performed, this is taken as a hint that the value
probably isn't semantically JSON, even if it's syntactically valid as
JSON.

(I've called this a bug fix in the title but could be a 'feat' too, I guess?)

Checklist

Breaking change checklist

RFC issue #: N/A

  • Migration process documented
  • Implement warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

This adjusts the default logging formatter (LambdaPowertoolsFormatter)
to handle non-structured logs with formatting, like:

    logger.info("foo %s", "bar")

This allows the formatter to be used in more situations, such as the
universal formatter for all log messages coming out of a system, even
libraries using the normal logging functionality, without explicit
support for aws-lambda-powertools.

If formatting is performed, this is taken as a hint that the value
probably isn't semantically JSON, even if it's syntactically valid as
JSON.
@huonw huonw force-pushed the formatted-logging branch from b1e3dba to 42f789e Compare May 7, 2021 04:43
@huonw huonw changed the title fix: Support .info("foo %s", "bar") formatting in logger fix(logger): Support .info("foo %s", "bar") formatting May 7, 2021
@heitorlessa
Copy link
Contributor

Hey @huonw thank you so much for this ;)

@heitorlessa heitorlessa merged commit 054f64c into aws-powertools:develop May 7, 2021
@huonw huonw deleted the formatted-logging branch May 7, 2021 10:14
@huonw
Copy link
Contributor Author

huonw commented May 7, 2021

Thanks for merging so quickly! (And thanks for your efforts on this library, it makes our app noticeably smoother.)

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.

2 participants