Currently:
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 */ this one's weird
PR_LOG_WARN = PR_LOG_WARNING, /* warning messages */ sigh whatever
PR_LOG_MIN = PR_LOG_DEBUG, /* minimal debugging messages */ wtf
PR_LOG_MAX = PR_LOG_DEBUG /* maximal debugging messages */ wtf
} PRLogModuleLevel;
Goal:
namespace mozilla {
enum class LogLevel {
Disabled = 0, // Logging is disabled for this module
Error, // console => error()
Warning, // console => warn()
Info, // console => info()
Debug, // console => debug (technically info)
};
}
So that gives us the following mappings:
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 |
*console.debug => console.info
- It's a misnomer, the output is not always logged, only if that module's logging is enabled
- A rough survey of usage indicates it should probably map to
Info
. Basically a level that is more thanDebug
, but not a warning and not an error.
- Fact: only used in 44 files
- Fact: shows up only once in 25 of those files
- Fact: 15 of those instances are comment only mentions
So:
- For files with only a comment, just remove it, now we have 29
- For the other files with one instance, just make it Info, we now have 19
- For the rest do a brief triage, if it looks like it could just be
Info
make itInfo
, if it takes more than 10 seconds of thought make itError
What do we do with code that is emulating a Verbose
level with PR_LOG_DEBUG + 1
? Now that we have a level b/w Debug
and Warn
(Info
) we can:
- Switch the usage of debug -> info
- Switch the usage of verbose -> debug
- Add enum class,
moz_test
function, update MOZ_LOG - Replace
PRLogModuleLevel
references w/mozilla::LogLevel
- Replace any
#define BLAH PR_LOG_(ERROR,WARNING,INFO,DEBUG,VERBOSE)
w/#define BLAH mozilla::LogLevel::
- Replace all remaining
PR_LOG_(ERROR,WARNING,INFO,DEBUG,VERBOSE)
w/LogLevel::
- Unbreak namespace issues by adding
using mozilla::LogLevel
in broken files