use macros from the log crate, issue #151

This commit is contained in:
Gambhiro 2016-08-14 13:32:34 +01:00
parent a7ae0b99c4
commit b584f6eb9c
7 changed files with 12 additions and 34 deletions

View File

@ -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 }

View File

@ -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);
}
{

View File

@ -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;

View File

@ -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)*) => ();
}

View File

@ -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,7 +130,7 @@ impl Renderer for HtmlHandlebars {
try!(index_file.write_all(content.as_bytes()));
output!("[*] Creating index.html from {:?} ✓",
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, ...)

View File

@ -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;
}

View File

@ -150,7 +150,7 @@ 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 {:?}",
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(),