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

feat(logging): Support logfmt #2712

Merged

Conversation

hairyhenderson
Copy link
Contributor

@hairyhenderson hairyhenderson commented Nov 22, 2024

Description

Adds logfmt support through a new logFormat global config setting. I ended up needing to refactor things a bit.

Also, the original TestLoggerOutput unit test actually wasn't testing the logger at all - that logger was being silently ignored. I fixed that test and merged it with the TestInitLogger test.

Closes issue(s)

Resolve #2711

Checklist

  • I have tested this code
  • I have added unit test to cover this code
  • I have updated the documentation (README.md and /website/docs)
  • I have followed the contributing guide

Copy link

netlify bot commented Nov 22, 2024

Deploy Preview for go-feature-flag-doc-preview ready!

Name Link
🔨 Latest commit a89c86f
🔍 Latest deploy log https://app.netlify.com/sites/go-feature-flag-doc-preview/deploys/6741b9ff01bad700081fe4a9
😎 Deploy Preview https://deploy-preview-2712--go-feature-flag-doc-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Signed-off-by: Dave Henderson <[email protected]>
@hairyhenderson hairyhenderson force-pushed the support-logfmt-logging-2711 branch from 4ead2ab to 34d3b14 Compare November 22, 2024 23:53
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.

Project coverage is 84.78%. Comparing base (c791fe1) to head (a89c86f).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/relayproxy/main.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2712      +/-   ##
==========================================
+ Coverage   84.74%   84.78%   +0.04%     
==========================================
  Files         111      111              
  Lines        5164     5180      +16     
==========================================
+ Hits         4376     4392      +16     
  Misses        624      624              
  Partials      164      164              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Comment on lines 454 to 456
if c.LogFormat != "" && c.LogFormat != "json" && c.LogFormat != "logfmt" {
return fmt.Errorf("invalid log format %s", c.LogFormat)
}
Copy link
Owner

@thomaspoignant thomaspoignant Nov 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💣 chore: ‏I have refactor this part to use a switch and lowercase the value.

I've also added a test to validate that we fail if we put something different.

Copy link
Owner

@thomaspoignant thomaspoignant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super nice addition, it may be easier to read proper text logs than JSON you are right.

🤓 nitpick: ‏I've added a small test and refactor a bit the validation part.
👏 praise: ‏Thanks a lot also for taking the time to fix the TestLoggerOutput.

I will put everything in the v1.39.0 version of GO Feature Flag.

@thomaspoignant thomaspoignant merged commit 440679d into thomaspoignant:main Nov 23, 2024
22 checks passed
@hairyhenderson hairyhenderson deleted the support-logfmt-logging-2711 branch November 23, 2024 21:31
@hairyhenderson
Copy link
Contributor Author

Thanks for the quick review @thomaspoignant!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(feature) Logging in logfmt format as well as json
2 participants