@@ -20,14 +20,20 @@ There are five macros that the logging subsystem uses:
20
20
21
21
* `log!(level, ...)` - the generic logging macro, takes a level as a u32 and any
22
22
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`
27
27
28
28
All of these macros use the same style of syntax as the `format!` syntax
29
29
extension. 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
31
37
32
38
## Enabling logging
33
39
@@ -95,6 +101,15 @@ use rt::local::Local;
95
101
use rt:: logging:: { Logger , StdErrLogger } ;
96
102
use rt:: task:: Task ;
97
103
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
+
98
113
/// This function is called directly by the compiler when using the logging
99
114
/// macros. This function does not take into account whether the log level
100
115
/// specified is active or not, it will always log something if this method is
0 commit comments