logrus_fluent icon indicating copy to clipboard operation
logrus_fluent copied to clipboard

customization of logrus.Level stringification

Open gcxRun opened this issue 6 years ago • 3 comments

Java loggers (default, logback) are using capital letters when stringifying log levels. This PR allows customizing how logrus.Level are stringified through fluentd so that when Java and Golang services logs are aggregated they are represented the same way.

gcxRun avatar Jun 15 '18 13:06 gcxRun

Please merge it!

siller174 avatar Dec 10 '19 15:12 siller174

@evalphobia merge please)

siller174 avatar Aug 06 '21 13:08 siller174

@gcxRun @siller174 Thank you for your patience, I forgot to answer it... 🙏 💦

After v0.5.4, you can use AddCustomizer to modify any fields.

hook.AddCustomizer(func(entry *logrus.Entry, data logrus.Fields) {
    data["level"] = "Hooked " + entry.Level.String()
})

This PR changes only level field and I thought others might want to change other fields, so AddCustomizer was added to support such kind modification.

Sorry to forgot to answer here and thank you for your contribution ❤️

evalphobia avatar Aug 13 '21 08:08 evalphobia