diff --git a/example/kitchen/Cargo.toml b/example/kitchen/Cargo.toml index 2eb60c9..4317757 100644 --- a/example/kitchen/Cargo.toml +++ b/example/kitchen/Cargo.toml @@ -6,4 +6,4 @@ edition = "2018" [dependencies] log = "0.4" -env_logger = "0.8" +env_logger = "0.9" diff --git a/example/puzzle_game/Cargo.toml b/example/puzzle_game/Cargo.toml index 2f8b91b..26e6ab5 100644 --- a/example/puzzle_game/Cargo.toml +++ b/example/puzzle_game/Cargo.toml @@ -8,4 +8,4 @@ edition = "2018" anyhow = "1.0" puzzles = { path = "../puzzles" } log = "0.4" -env_logger = "0.8" +env_logger = "0.9" diff --git a/exercise/logging/Cargo.toml b/exercise/logging/Cargo.toml index 3e8797f..277d20e 100644 --- a/exercise/logging/Cargo.toml +++ b/exercise/logging/Cargo.toml @@ -6,7 +6,9 @@ edition = "2018" [dependencies] # I'm glad you came to add the `log` dependency! I got it all ready for you, just uncomment: -log = "0.4" +# +# log = "0.4" # And here's the env_logger dependency that you'll need in main.rs -env_logger = "0.8" +# +# env_logger = "0.9" diff --git a/exercise/logging/src/lib.rs b/exercise/logging/src/lib.rs index 845d4d8..3b447f6 100644 --- a/exercise/logging/src/lib.rs +++ b/exercise/logging/src/lib.rs @@ -1,9 +1,10 @@ -// 1. Bring the macros error, warn, info, debug, and trace into scope from the log package with a +// 1. Bring the macros `error, warn, info, debug, trace` into scope from the log package with a // `use` statement. // -// - You should be able to run `cargo build --lib` successfully after each step. +// You should be able to run `cargo build --lib` successfully after this step (and each step in this +// file) // -// Hint: You may need to update Cargo.toml first +// Hint: You need to update Cargo.toml to add the `log` dependency, first. #[derive(Debug)] pub struct Frog { @@ -17,14 +18,13 @@ impl Frog { Default::default() } pub fn hop(&mut self) { - // 3. Use info!() to log that a Frog hopped, and how much energy is left self.energy -= 1; + // 3. Use info!() to log that a Frog hopped, and how much energy is left if self.energy == 0 { // 4. Use warn!() to warn that the frog will go to sleep since he ran out of energy self.sleep(); } } - // info, error pub fn sleep(&mut self) { if !self.sleeping { // 5. Use error!() to log a (non-fatal) error stating that the Frog is already asleep diff --git a/exercise/logging/src/main.rs b/exercise/logging/src/main.rs index 71d4e39..c4f1161 100644 --- a/exercise/logging/src/main.rs +++ b/exercise/logging/src/main.rs @@ -2,16 +2,16 @@ use frogger::Frog; -// You did 1-6 in lib.rs already, right? +// You did #1-#6 in lib.rs already, right? // -// 7. Bring env_logger into scope. You might need to update Cargo.toml, first. +// 7. Update Cargo.toml to add the `env_logger` dependency fn main() { - // 8. Initialize env_logger using the init() function + // 8. Initialize env_logger using the init() function at the top level of the library // 9. Run this program with `cargo run` and take a look at the default output. // - Now run it again with an explicit log level, like `RUST_LOG=info cargo run` - // - ...and `RUST_LOG=trace cargo run` + // - or `RUST_LOG=trace cargo run` let mut skippy = Frog::new(); skippy.hop(); skippy.hop();