logrus
logrus copied to clipboard
Allow to print log level as integer
Reason
To be able to have logs compliant with the Syslog Protocol (RFC5424 and RFC3164), we need to print the log levels as integers.
Changes
Adds a flag to both Text and JSON Formatters struct that, if set to true, will make the log levels print as integers (the default is the old behaviour, i.e. print the resolved level name).
Issues
Fixes #355.
I'm a little worried about the impact of exposing the internal log levels as an API. There are other PRs that add levels and even change the numbering base, so I'm worried this would prevent those changes from happening by making the level's value, rather than its name, an external API.
Maybe the way to go would be to have both: level
for the level number and level_name
for the respective name, ideally by default.
@jmdalmeida I just can't see the reason to have the number by default, and we definitely can't switch level
to be a number. It would just break way to many users for an uncommon use case.
Have you tried using a formatter to get the output you're looking for?