pamburus/hl

Add support for logfmt

Pavinati opened this issue · 6 comments

I would love to be able to use hl for logfmt logs.
Any chance this could be added as supported format?
For me, that's the only reason i keep using humanlog

Hi ,

Thank you for your interest.
I looked at this format and did some research on how easily it can be integrated.

This is my first and only project in rust, and I was just learning the language trying to make something useful, and one of the goals was high performance. Together with a little confidence in the language, that goal led to some pretty coupled code. Currently, partly-parsed JSON is everywhere, and it is processed even when formatting output.

Actually, it seems doable, but with limited functionality, and will be quite challenging.

Implemented.
Please check v0.27.0-beta.1

I had a quick test on couple of logs and it appears to be working as intended, thanks!

Great, feel free to submit any bugs or suggestions if anything comes up.

Hi @Pavinati,

Could you please try v0.27.0-beta.2 and confirm that everything still works in your scenarios?
I added restrictions on the allowed logfmt format due to unstructured logs being parsed as logfmt and displaying as unreadable garbage, which was undesirable behavior.
Unfortunately, there is no standard specification for logfmt. The original article describing it only provides a general overview of the format's structure. However, there are a few reference implementations available. Initially, I followed these implementations, but they have the exact same difficulty parsing unstructured logs and may display them as garbage.
Checked how humanlog handles this and found that it also adds a limitation to prevent this - it just checks that the line contains = sign. I found this measure scant and decided to add a little bit more restrictions. You can check the linked pull requests for more details.

Sorry for the late answer, i couldn't test this before. I tested with the released 0.27.2 and it works great!