Skip to content

use macros from the log crate, issue #151 #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ clap = "2.2.1"
handlebars = "0.20.0"
rustc-serialize = "0.3.18"
pulldown-cmark = "0.0.8"
log = "0.3"
env_logger = "0.3.4"

# Watch feature
notify = { version = "2.5.5", optional = true }
Expand Down
5 changes: 5 additions & 0 deletions src/bin/mdbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
extern crate mdbook;
#[macro_use]
extern crate clap;
#[macro_use]
extern crate log;
extern crate env_logger;

// Dependencies for the Watch feature
#[cfg(feature = "watch")]
Expand Down Expand Up @@ -38,6 +41,8 @@ use mdbook::MDBook;
const NAME: &'static str = "mdbook";

fn main() {
env_logger::init().unwrap();

// Create a list of valid arguments and sub-commands
let matches = App::new(NAME)
.about("Create a book in form of a static website from markdown files")
Expand Down
4 changes: 2 additions & 2 deletions src/book/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
warn!("{:?} No directory with that name", root);
}

MDBook {
Expand Down Expand Up @@ -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);
}

{
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 0 additions & 23 deletions src/macros.rs

This file was deleted.

8 changes: 4 additions & 4 deletions src/renderer/html_handlebars/hbs_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));

Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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, ...)

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/html_handlebars/helpers/playpen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
warn!("[-] No file exists for {{{{#playpen }}}}\n {}", playpen.rust_file.to_str().unwrap());
continue;
}

Expand Down
6 changes: 3 additions & 3 deletions src/utils/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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..."))));
}
Expand Down