Skip to content

bpo-44722: Added a Multiline Formatter #27301

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

Conversation

creative-resort
Copy link

@creative-resort creative-resort commented Jul 23, 2021

RFC: string Multiline Formatter

I'd like to contribute a multiline formatter to the string library.
This is a first draft, that I've so far done basic testing for.

Please let me know your thoughts. I am sure it can be further improved.

The idea:

Format strings

  • that are comprised of field values with newlines (Multiline)
  • as Multiline strings in a quasi tabbed format.

This is in particular useful for logging of information, that occupies multiple lines.

For example:

Given the format string '{levelname}:{name}:{message}:{api}',
where the message and the api field is a string with multiple lines (contains newlines) ...

Result:

... Is formatted as:

2021-07-23 09:50:28,981 module_name WARNING     Quota exceeded         Google-Cloud-API
                                                Backing off for 5s     version: v1
                                                after trying 2x

https://bugs.python.org/issue44722

In addition to the basic string Formatter, the Multiline Formatter is able to handle fields with multiline values.
- Has been tested.
- Can be further improved on, e.g. to take into account field width limits
@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@creative-resort

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

@creative-resort creative-resort changed the title 44722: Added a Multiline Formatter bpo-44722: Added a Multiline Formatter Jul 23, 2021
@creative-resort creative-resort deleted the creative-resort-string-format-multiline branch July 24, 2021 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants