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

zapcore: add warning as Level #1429

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

florianl
Copy link

Some packages set their value for WarnLevel to "warning". For easier integration add "warning" as accepted WarnLevel.

Example for a package that is using "warning":
https://github.com/sirupsen/logrus/blob/dd1b4c2e81afc5c255f216a722b012ed26be57df/logrus.go#L68

Some packages set their value for WarnLevel to "warning". For easier integration
add "warning" as accepted WarnLevel.

Example for a package that is using "warning":
https://github.com/sirupsen/logrus/blob/dd1b4c2e81afc5c255f216a722b012ed26be57df/logrus.go#L68

Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
@CLAassistant
Copy link

CLAassistant commented Apr 11, 2024

CLA assistant check
All committers have signed the CLA.

@florianl
Copy link
Author

Friendly ping for feedback to @abhinav or @JacobOaks .
Thanks in advance 🙏

@r-hang
Copy link
Contributor

r-hang commented Apr 23, 2024

Hey @florianl, I think this change incurs some technical debt for a small amount of flexibility. The current level MarshalText logic is simplified because there is either a capitalized or lower case representation of the each level, where the level is represented in a consistent tense.

From my perspective, the special check case in level_test.go makes the level test code a bit more difficult to main.

@florianl
Copy link
Author

Hey @r-hang thanks for the feedback!
I agree with you, that current level MarshalText logic is simplified and should stay that way.

There are cases where this packages is expected to handle input, that is generated from other packages, that are using the same levels, but slightly different level text - warning instead of warn. Currently this package is not able to pick up these slightly differences. In such cases where this package is expected to handle input with level warning, it will ignore this level, and will instead use level=info - which is not correct.
The intention of this PR is, that this package is able to handle input that originates from other sources and transparently uses the correct level.

Copy link

codecov bot commented Apr 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.69%. Comparing base (b15585b) to head (3aefb87).
Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1429   +/-   ##
=======================================
  Coverage   98.69%   98.69%           
=======================================
  Files          53       53           
  Lines        2997     2997           
=======================================
  Hits         2958     2958           
  Misses         31       31           
  Partials        8        8           

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

@florianl
Copy link
Author

@r-hang what do you think about having a dedicated test for unmarshaling warning rather mixing it with the existing TestLevelText? This should decrease the maintenance level in the test you have mentioned.

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

Successfully merging this pull request may close these issues.

None yet

3 participants