-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add support for logfmt #7
Comments
Would you mind posting an example of the desired usage and output? |
It's structured like JSON but a bit more readable. Plenty of examples in that posted link. |
Based on the links, the clearest example I saw was from here: foo=bar a=14 baz="hello kitty" cool%story=bro f %^asdf You can get something like that with the custom logger: import pygogo as gogo
kwargs = {'f': True}
extra = {'foo': 'bar, 'a': 14, 'baz': 'hello kitty', 'story': 'bro'}
logfmt = 'foo="%(foo)s" a="%(a)s" baz="%(baz)s" cool_story="%(story)s" "%(message)s"'
fmtr = logging.Formatter(logfmt)
logger = gogo.Gogo('custom', low_formatter=fmtr).get_logger(**kwargs)
logger.debug('%^asdf', extra=extra)
# Prints the following to `stdout`:
foo=bar a=14 baz="hello kitty" cool_story=bro %^asdf Is that what you are talking about? |
Yes, except everything is key value, even the message (message="%^asdf"). And there has to be smart quoting "" for spaces and strings with quotes. |
@offero, unfortunately, the link I posted above doesn't match what you just said. They don't display keys for the last two values. Can you please show a complete usage example for what you are looking to achieve? Thanks! |
logfmt (second article) is a format meant to be between JSON and normal logs for (human) readability and (machine) parse-ability.
Any chance it could be added to pygogo? I might have a go myself, but thought I'd ask at least.
The text was updated successfully, but these errors were encountered: