As part of the effort to improve logging in gecko we'd like to introduce a new set of unified log levels.
Currently we use NSPR logging which defines the following log levels: typedef enum PRLogModuleLevel { PR_LOG_NONE = 0, /* nothing */ PR_LOG_ALWAYS = 1, /* always printed */ <---- lies, damned lies PR_LOG_ERROR = 2, /* error messages */ PR_LOG_WARNING = 3, /* warning messages */ PR_LOG_DEBUG = 4, /* debug messages */ PR_LOG_NOTICE = PR_LOG_DEBUG, /* notice messages */ PR_LOG_WARN = PR_LOG_WARNING, /* warning messages */ PR_LOG_MIN = PR_LOG_DEBUG, /* minimal debugging messages */ PR_LOG_MAX = PR_LOG_DEBUG /* maximal debugging messages */ } PRLogModuleLevel; After a rather thorough examination of usages of each I have come up with a set that I believe would fit our needs: enum class LogLevel { Disabled = 0, // Logging is disabled for this module Error, Warning, Info, Debug, }; This subset maps rather nicely to syslog and web console logging levels: | Level | PR_LOG | Console | Syslog | |---------|----------------|-------------------|---------| | Error | PR_LOG_ERROR | console.error() | error | | Warning | PR_LOG_WARNING | console.warn() | warning | | Info | n/a | console.info() | info | | Debug | PR_LOG_DEBUG | console.debug()* | debug | This removes all of the various PR_LOG aliases as well as |PR_LOG_ALWAYS|. It adds a generic |Info| level. *PR_LOG_ALWAYS* This really didn't mean what most uses thought it meant. Specifying |PR_LOG_ALWAYS| did not in fact mean your message was always logged, it just mean it was logged if at least log level 1 was specified. By default every logger has output disabled. For most instances it can be replaced with |Info|, a more generic log category that is slightly more important than |Debug|, but not an error or warning. *PR_LOG_DEBUG + 1 aka log level 5* Various bits of code invented a log level that was less important than debug (I would call this verbose). This was not specified in NSPR logging, but just kind of worked. With the addition of |Info| we can transition code that was using this pseudo log level to: - map PR_LOG_DEBUG => Info - map PR_LOG_DEBUG + 1 => Debug In this case we could have added a |Verbose| log level, but with the addition of |Info| and feeling that fewer is better we have decided against that. *How will log levels be controlled?* Similar to how it works now (if not terribly clear), turning on: - LogLevel::Error => Error messages will be printed - LogLevel::Warning => Error and Warning messages will be printed - LogLevel::Info => Error, Warning, and Info messages will be printed - LogLevel::Debug => Error, Warning, Info, and Debug messages will be printed As a future improvement we plan to add the ability to toggle this levels at runtime. Please let me know of any concerns or input you may have. -e _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform