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

StringTemplateStyle ($) does not support unbraced names #18

Open
nhairs opened this issue Jul 17, 2024 · 1 comment
Open

StringTemplateStyle ($) does not support unbraced names #18

nhairs opened this issue Jul 17, 2024 · 1 comment
Labels
bug Something isn't working open for work PRs welcome

Comments

@nhairs
Copy link
Owner

nhairs commented Jul 17, 2024

Original Issue: madzak/python-json-logger#194

Fix regex for string template style

valid String template: '$asctime $level $message'

regex for string template in JsonFormatter.parse:

....
        elif isinstance(self._style, logging.StrFormatStyle):
            formatter_style_pattern = re.compile(r"\{(.+?)\}", re.IGNORECASE)
...

would require the string template to be '${asctime} ${level} ${message}'

@nhairs nhairs added bug Something isn't working open for work PRs welcome labels Jul 17, 2024
@nhairs nhairs changed the title Format ($) style does not support unbraced names StrtFormatStyle ($) does not support unbraced names Jul 17, 2024
@nhairs nhairs changed the title StrtFormatStyle ($) does not support unbraced names StringTemplateStyle ($) does not support unbraced names Jul 21, 2024
@nhairs
Copy link
Owner Author

nhairs commented Jul 21, 2024

Rereading this, I'm not entirely sure if this is referring to StrFormatStyle aka style="{" or StringTemplateStyle aka style="$".

I think it's referring to StringTemplateStyle as String Templates allow using $var and ${var} for substitutions (but not {var}).

However the snippet from the original issue is showing the line form StrFormatStyle. I'll note that as far as I can tell from the docs str.format does not use $ for it's variable marker.

@Thomasillo are you able to clarify which format you believe the issue with?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working open for work PRs welcome
Projects
None yet
Development

No branches or pull requests

1 participant