-
Notifications
You must be signed in to change notification settings - Fork 22
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
Level 1 and 2+ should map to corresponding Logrus Debug and Trace levels #11
Comments
Hello, thanks for the report! I thought this was how it was implemented, is it not? Right now, Have a look at this example: package main
import (
"fmt"
"github.com/bombsimon/logrusr/v2"
"github.com/sirupsen/logrus"
)
func main() {
testWithlevel(logrus.InfoLevel)
testWithlevel(logrus.DebugLevel)
testWithlevel(logrus.TraceLevel)
}
func testWithlevel(level logrus.Level) {
logrusLog := logrus.New()
logrusLog.SetLevel(level)
log := logrusr.New(logrusLog)
log.V(0).WithName(level.String()).Info("logging v0")
log.V(1).WithName(level.String()).Info("logging v1")
log.V(2).WithName(level.String()).Info("logging v2")
fmt.Println("---")
} This will output the following which I think is correct. INFO[0000] logging v0 logger=info
---
INFO[0000] logging v0 logger=debug
INFO[0000] logging v1 logger=debug
---
INFO[0000] logging v0 logger=trace
INFO[0000] logging v1 logger=trace
INFO[0000] logging v2 logger=trace
--- |
Thanks for checking. Indeed I confirm that the example you posted is not correct. The lines logged with V1 should show up as DEBUG not as INFO. |
The background of Further down in the readme you'll find both the section Why V-levels? and Why not named levels, like Info/Warning/Error? explaining this. So basically the key concept is to only have |
Yes I understand - still why not emulate logrus behavior by deriving from the level similar to what is described in https://github.com/go-logr/zapr#increasing-verbosity for zap and https://github.com/go-logr/zerologr#implementation-details for zerolog. I think whatever logging system one chooses, the logr levels should be translated as close as possible with modules like this. We cannot change that logrus has debug and trace levels and they can be easily emulated by level 1 and level 2+ not only for the actual enabled check bit also on the actual output side so that logrus getting triggered via logr actually behave similar like native logrus logging. Maybe I got it wrong but isn't that the purpose of this module? |
Thanks for the examples! Since they both come from the maintainers of I guess the expected output given the above examples would be this: INFO[0000] logging v0 logger=info
---
INFO[0000] logging v0 logger=debug
DEBU[0000] logging v1 logger=debug
---
INFO[0000] logging v0 logger=trace
DEBU[0000] logging v1 logger=trace
TRAC[0000] logging v2 logger=trace |
Since this is a breaking change I'll draft a new major release but I want to add some more things before doing that as well! |
Yes - thank you 👍 |
Sure, i don't see much of a "break" in the sense that something will stop working because of this. To me this seems more like a bug fix. |
You never know peoples workflows and how they work with logs. If someone has a workflow where they filter on log severity this would break filters expecting info, or a filter that only looks for |
It would be great if this library would map level 0 to logrus.Info, level 1 to logrus.debug and all higher levels to logrus.trace to preserve the log level indicator in logrus output. That would make instant adoption of existing logrus code easier and impact free.
The text was updated successfully, but these errors were encountered: