-
Notifications
You must be signed in to change notification settings - Fork 22
feat: ✨ Add option to unescape strings inside log string #48
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
mohammed90
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR! It's a good change, simplifying log processing. Just a minor change to be more idiomatic, and it'll be good. I love the tests 🙂
| if !unescapeStrings { | ||
| return value, true | ||
| } else { | ||
| str, _ := jsonparser.ParseString(value) | ||
| return str, true | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be shortened like this:
| if !unescapeStrings { | |
| return value, true | |
| } else { | |
| str, _ := jsonparser.ParseString(value) | |
| return str, true | |
| } | |
| if !unescapeStrings { | |
| return value, true | |
| } | |
| return jsonparser.ParseString(value), true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change done
Though we can't return jsonparser.ParseString() result directly, as it is a tuple (str, err)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad 🤦🏻♂️ Thank you for catching it
|
@mohammed90 |
|
I'm sorry, forgot to mention it the first time. Can you lose stretcher/testify? |
Lose stretcher/testify ? |
@mohammed90 |
44d50ed to
b37ec86
Compare
b37ec86 to
2d7b2fe
Compare
I mean could you remove the dependency on the testify package?
Thanks for the find! I see this comes from the Caddyfile lexer. The lexer area isn't my strongest. @mholt, @francislavoie, I see the same unavoidable escape when doing |
|
Just use a literal tab character in the Caddyfile 🤷 it wasn't designed to support escape sequences. |
|
@mohammed90 |
mohammed90
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you for the contribution 🎉
Unescaping string fields can be useful to have a readable console log