New log-level like info #240

Closed
opened 2017-10-29 06:08:37 -05:00 by jo-so · 6 comments
jo-so commented 2017-10-29 06:08:37 -05:00 (Migrated from github.com)

I would like to use another log-level similar to INFO, like the Unix syslog uses LOG_NOTICE. Would it be possible to extend the crate this way?

http://man7.org/linux/man-pages/man3/syslog.3.html

I would like to use another log-level similar to INFO, like the Unix syslog uses LOG_NOTICE. Would it be possible to extend the crate this way? http://man7.org/linux/man-pages/man3/syslog.3.html
sfackler commented 2017-10-29 12:33:01 -05:00 (Migrated from github.com)

I'm a bit uncomfortable with making changes like this, since it seems like you'd end up supporting every level used by every logging thing in existence.

I'm a bit uncomfortable with making changes like this, since it seems like you'd end up supporting every level used by every logging thing in existence.
jo-so commented 2017-11-01 11:29:04 -05:00 (Migrated from github.com)

Yes, it would open up they way to request each possible loglevel.

Maybe it's possible (with an API-break) to use an u8 instead of an enum and define the macros with 40 = trace, 80 = debug, …, 200 = error and leave it up to the logger how to handle the values. A syslog logger might map everything <= 80 to debug, 81…120 to info, 121…140 to notice, 161…200 error, 201…220 critical, 221…240 alert, 241…255 emergency.

Yes, it would open up they way to request each possible loglevel. Maybe it's possible (with an API-break) to use an u8 instead of an enum and define the macros with 40 = trace, 80 = debug, …, 200 = error and leave it up to the logger how to handle the values. A syslog logger might map everything <= 80 to debug, 81…120 to info, 121…140 to notice, 161…200 error, 201…220 critical, 221…240 alert, 241…255 emergency.
sfackler commented 2017-11-01 11:32:52 -05:00 (Migrated from github.com)

Now every logger has to decide how they render log level 43 vs log level 47.

Now every logger has to decide how they render log level 43 vs log level 47.
sfackler commented 2017-11-01 11:34:24 -05:00 (Migrated from github.com)

And libraries that want to log things need to decide if they want to use log level 43 vs log level 47.

And libraries that want to log things need to decide if they want to use log level 43 vs log level 47.
jo-so commented 2017-11-01 14:50:25 -05:00 (Migrated from github.com)

Yes, right, that sounds helpful. This would open the logging system for extensions. Libs or apps which are targeting syslog for example, might include a syslog crate which provides the additional macros for the other loglevels.

Yes, right, that sounds helpful. This would open the logging system for extensions. Libs or apps which are targeting syslog for example, might include a syslog crate which provides the additional macros for the other loglevels.
sfackler commented 2017-11-01 14:57:25 -05:00 (Migrated from github.com)

If a crate knows it's only targeting syslog, it can use a syslog-specific logger that has all of the levels it cares about.

I'm talking about the vast majority of crates that don't know or care what kind of logger they are being hooked into.

If a crate knows it's only targeting syslog, it can use a syslog-specific logger that has all of the levels it cares about. I'm talking about the *vast* majority of crates that don't know or care what kind of logger they are being hooked into.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-rust-lang/log#240
No description provided.