logrus icon indicating copy to clipboard operation
logrus copied to clipboard

Allow to print log level as integer

Open jmdalmeida opened this issue 7 years ago • 3 comments

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.

jmdalmeida avatar Jan 31 '18 00:01 jmdalmeida

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.

stevvooe avatar Mar 29 '18 21:03 stevvooe

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 avatar Mar 29 '18 22:03 jmdalmeida

@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?

stevvooe avatar Mar 29 '18 22:03 stevvooe