logkit using logrus strange behaviour #1149
-
Hi,
This prints: Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Thanks for the questions, @SofiaTa. For most projects the go-kit log package should be an alternative to logrus rather than a wrapper around it. As a result, I don't think the logrus adapter has been used very much and it likely has many short comings. It appears you have found two of them. The current implementation of the logrus adapter is very simple. You can see its history in #759 and #793. I will try to answer your questions below.
Yes, i can reproduce the behavior you describe. This happens because the logrus data model has a special The go-kit log package, on the other hand, does not define any special keys, allowing applications to have full control of the keys in their logs. That is a fundamental design difference between the two packages and it leaves the logrus adapter with a question of how to handle that difference. The current implementation takes the simplest approach of not doing anything special to populate the logrus I am not sure we should change that, but I am open to suggestions.
There was no specific discussion of how to translate log levels from the go-kit log/levels package into logrus levels. Perhaps that was not a requirement of the original authors of the logrus adapter. The current implementation makes no attempt to consider the log/levels package and just always uses the logrus |
Beta Was this translation helpful? Give feedback.
-
Thanks for your quick answer @ChrisHines 👍
This prints
You can see the "missing" entry in the log if you don't provide the key "msg" , I'm not really understand why its mandatory ? there is a cases when you want to log only one statement/message , is there a way to avoid it ? |
Beta Was this translation helpful? Give feedback.
-
Go kit's package log implements a concept called structured logging, which mandates logging key-value pairs rather than simple strings. Concretely, that means every call to Log requires pairs of arguments, never single or odd-numbered arguments. This was an early design decision and not one that's going to change. |
Beta Was this translation helpful? Give feedback.
Thanks for the questions, @SofiaTa.
For most projects the go-kit log package should be an alternative to logrus rather than a wrapper around it. As a result, I don't think the logrus adapter has been used very much and it likely has many short comings. It appears you have found two of them.
The current implementation of the logrus adapter is very simple. You can see its history in #759 and #793.
I will try to answer your questions below.
Yes, i can reproduce th…