@@ -20,14 +20,20 @@ There are five macros that the logging subsystem uses:
2020
2121* `log!(level, ...)` - the generic logging macro, takes a level as a u32 and any
2222 related `format!` arguments
23- * `debug!(...)` - a macro hard-wired to the log level of 4
24- * `info!(...)` - a macro hard-wired to the log level of 3
25- * `warn!(...)` - a macro hard-wired to the log level of 2
26- * `error!(...)` - a macro hard-wired to the log level of 1
23+ * `debug!(...)` - a macro hard-wired to the log level of `DEBUG`
24+ * `info!(...)` - a macro hard-wired to the log level of `INFO`
25+ * `warn!(...)` - a macro hard-wired to the log level of `WARN`
26+ * `error!(...)` - a macro hard-wired to the log level of `ERROR`
2727
2828All of these macros use the same style of syntax as the `format!` syntax
2929extension. Details about the syntax can be found in the documentation of
30- `std::fmt` along with the Rust tutorial/manual
30+ `std::fmt` along with the Rust tutorial/manual.
31+
32+ If you want to check at runtime if a given logging level is enabled (e.g. if the
33+ information you would want to log is expensive to produce), you can use the
34+ following macro:
35+
36+ * `log_enabled!(level)` - returns true if logging of the given level is enabled
3137
3238## Enabling logging
3339
@@ -95,6 +101,15 @@ use rt::local::Local;
95101use rt:: logging:: { Logger , StdErrLogger } ;
96102use rt:: task:: Task ;
97103
104+ /// Debug log level
105+ pub static DEBUG : u32 = 4 ;
106+ /// Info log level
107+ pub static INFO : u32 = 3 ;
108+ /// Warn log level
109+ pub static WARN : u32 = 2 ;
110+ /// Error log level
111+ pub static ERROR : u32 = 1 ;
112+
98113/// This function is called directly by the compiler when using the logging
99114/// macros. This function does not take into account whether the log level
100115/// specified is active or not, it will always log something if this method is
0 commit comments