parent
260d74dfcc
commit
d79b22474c
1 changed files with 22 additions and 0 deletions
22
doc/rust.md
22
doc/rust.md
|
@ -3251,6 +3251,28 @@ of runtime logging modules follows.
|
||||||
* `::rt::backtrace` Log a backtrace on task failure
|
* `::rt::backtrace` Log a backtrace on task failure
|
||||||
* `::rt::callback` Unused
|
* `::rt::callback` Unused
|
||||||
|
|
||||||
|
#### Logging Expressions
|
||||||
|
|
||||||
|
Rust provides several macros to log information. Here's a simple Rust program
|
||||||
|
that demonstrates all four of them:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
fn main() {
|
||||||
|
error!("This is an error log")
|
||||||
|
warn!("This is a warn log")
|
||||||
|
info!("this is an info log")
|
||||||
|
debug!("This is a dubug log")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
These four log levels correspond to levels 1-4, as controlled by `RUST_LOG`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ RUST_LOG=rust=3 ./rust
|
||||||
|
rust: ~"\"This is na error log\""
|
||||||
|
rust: ~"\"This is a warn log\""
|
||||||
|
rust: ~"\"this is an info log\""
|
||||||
|
```
|
||||||
|
|
||||||
# Appendix: Rationales and design tradeoffs
|
# Appendix: Rationales and design tradeoffs
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue