diff --git a/Cargo.toml b/Cargo.toml index bff8e9bd..0af11c45 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ clap = "2.2.1" handlebars = "0.20.0" rustc-serialize = "0.3.18" pulldown-cmark = "0.0.8" +log = "0.3" # Watch feature notify = { version = "2.5.5", optional = true } diff --git a/src/book/mod.rs b/src/book/mod.rs index 4e64092c..9a2f17c4 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -42,7 +42,7 @@ impl MDBook { pub fn new(root: &Path) -> MDBook { if !root.exists() || !root.is_dir() { - output!("{:?} No directory with that name", root); + info!("{:?} No directory with that name", root); } MDBook { @@ -116,7 +116,7 @@ impl MDBook { if !self.root.exists() { fs::create_dir_all(&self.root).unwrap(); - output!("{:?} created", &self.root); + info!("{:?} created", &self.root); } { diff --git a/src/lib.rs b/src/lib.rs index 91aa9fa9..2bc34fec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -73,7 +73,7 @@ extern crate rustc_serialize; extern crate handlebars; extern crate pulldown_cmark; -#[macro_use] pub mod macros; +#[macro_use] extern crate log; pub mod book; mod parse; pub mod renderer; diff --git a/src/macros.rs b/src/macros.rs deleted file mode 100644 index 551eded8..00000000 --- a/src/macros.rs +++ /dev/null @@ -1,23 +0,0 @@ -#[cfg(feature = "debug")] -macro_rules! debug { - ($fmt:expr) => (println!($fmt)); - ($fmt:expr, $($arg:tt)*) => (println!($fmt, $($arg)*)); -} - -#[cfg(not(feature = "debug"))] -macro_rules! debug { - ($fmt:expr) => (); - ($fmt:expr, $($arg:tt)*) => (); -} - -#[cfg(feature = "output")] -macro_rules! output { - ($fmt:expr) => (println!($fmt)); - ($fmt:expr, $($arg:tt)*) => (println!($fmt, $($arg)*)); -} - -#[cfg(not(feature = "output"))] -macro_rules! output { - ($fmt:expr) => (); - ($fmt:expr, $($arg:tt)*) => (); -} diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index dd53a040..15a6894f 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -108,7 +108,7 @@ impl Renderer for HtmlHandlebars { // Write to file let mut file = try!(utils::fs::create_file(&book.get_dest().join(&ch.path).with_extension("html"))); - output!("[*] Creating {:?} ✓", &book.get_dest().join(&ch.path).with_extension("html")); + info!("[*] Creating {:?} ✓", &book.get_dest().join(&ch.path).with_extension("html")); try!(file.write_all(&rendered.into_bytes())); @@ -130,8 +130,8 @@ impl Renderer for HtmlHandlebars { try!(index_file.write_all(content.as_bytes())); - output!("[*] Creating index.html from {:?} ✓", - book.get_dest().join(&ch.path.with_extension("html"))); + info!("[*] Creating index.html from {:?} ✓", + book.get_dest().join(&ch.path.with_extension("html"))); index = false; } } @@ -159,7 +159,7 @@ impl Renderer for HtmlHandlebars { let rendered = try!(handlebars.render("index", &data)); let mut file = try!(utils::fs::create_file(&book.get_dest().join("print").with_extension("html"))); try!(file.write_all(&rendered.into_bytes())); - output!("[*] Creating print.html ✓"); + info!("[*] Creating print.html ✓"); // Copy static files (js, css, images, ...) diff --git a/src/renderer/html_handlebars/helpers/playpen.rs b/src/renderer/html_handlebars/helpers/playpen.rs index da04552b..ed76e9ba 100644 --- a/src/renderer/html_handlebars/helpers/playpen.rs +++ b/src/renderer/html_handlebars/helpers/playpen.rs @@ -20,7 +20,7 @@ pub fn render_playpen(s: &str, path: &Path) -> String { // Check if the file exists if !playpen.rust_file.exists() || !playpen.rust_file.is_file() { - output!("[-] No file exists for {{{{#playpen }}}}\n {}", playpen.rust_file.to_str().unwrap()); + info!("[-] No file exists for {{{{#playpen }}}}\n {}", playpen.rust_file.to_str().unwrap()); continue; } diff --git a/src/utils/fs.rs b/src/utils/fs.rs index bb4aa7f0..9e268646 100644 --- a/src/utils/fs.rs +++ b/src/utils/fs.rs @@ -150,9 +150,9 @@ pub fn copy_files_except_ext(from: &Path, to: &Path, recursive: bool, ext_blackl debug!("[*] creating path for file: {:?}", &to.join(entry.path().file_name().expect("a file should have a file name..."))); - output!("[*] Copying file: {:?}\n to {:?}", - entry.path(), - &to.join(entry.path().file_name().expect("a file should have a file name..."))); + info!("[*] Copying file: {:?}\n to {:?}", + entry.path(), + &to.join(entry.path().file_name().expect("a file should have a file name..."))); try!(fs::copy(entry.path(), &to.join(entry.path().file_name().expect("a file should have a file name...")))); }