From d79b22474cf9b02d0d3a0a78f8c6ef279770c36b Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 3 Apr 2013 11:40:23 -0700 Subject: [PATCH 1/3] Add information about logging macros to the tutorial. Closes #5699. --- doc/rust.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/doc/rust.md b/doc/rust.md index c6dba962676..eceb308b4f6 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -3251,6 +3251,28 @@ of runtime logging modules follows. * `::rt::backtrace` Log a backtrace on task failure * `::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 From 3044f5e2b64ae8c0ee726ec42f3d2a3faca9e77e Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 3 Apr 2013 12:44:41 -0700 Subject: [PATCH 2/3] typo fix: na -> an --- doc/rust.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/rust.md b/doc/rust.md index eceb308b4f6..1cb8b7053b5 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -3269,7 +3269,7 @@ 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 an error log\"" rust: ~"\"This is a warn log\"" rust: ~"\"this is an info log\"" ``` From a7f0bfbda65d6ac2494d2270a96f45570dfb552e Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 3 Apr 2013 16:59:13 -0700 Subject: [PATCH 3/3] One more typo: dubug -> debug --- doc/rust.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/rust.md b/doc/rust.md index 1cb8b7053b5..d70fcded5e7 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -3261,7 +3261,7 @@ 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") + debug!("This is a debug log") } ```