Sirupsen/logrus: Difference between revisions
Jump to navigation
Jump to search
Line 19: | Line 19: | ||
"field2": value2 | "field2": value2 | ||
}).Error("Constant string error message") | }).Error("Constant string error message") | ||
} | |||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 17:23, 4 September 2024
External
Internal
Overview
Logrus is in maintenance-mode. From the author: I believe Logrus' biggest contribution is to have played a part in today's widespread use of structured logging in Golang. There doesn't seem to be a reason to do a major, breaking iteration into Logrus V2, since the fantastic Go community has built those independently. Many fantastic alternatives have sprung up. Logrus would look like those, had it been re-designed with what we know about structured logging in Go today. Check out, for example, Zerolog, Zap, and Apex.
Idioms
Constant String Logging
if err != nil {
logger.WithError(err).WithFields(logrus.Fields{
"field1": value1,
"field2": value2
}).Error("Constant string error message")
}