Skip to content

Commit 8f8893b

Browse files
authored
Merge pull request #164 from gambhiro/use-log-crate
use macros from the log crate, issue #151
2 parents a7ae0b9 + 4153db2 commit 8f8893b

File tree

8 files changed

+18
-34
lines changed

8 files changed

+18
-34
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ clap = "2.2.1"
1919
handlebars = "0.20.0"
2020
rustc-serialize = "0.3.18"
2121
pulldown-cmark = "0.0.8"
22+
log = "0.3"
23+
env_logger = "0.3.4"
2224

2325
# Watch feature
2426
notify = { version = "2.5.5", optional = true }

src/bin/mdbook.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
extern crate mdbook;
33
#[macro_use]
44
extern crate clap;
5+
#[macro_use]
6+
extern crate log;
7+
extern crate env_logger;
58

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

4043
fn main() {
44+
env_logger::init().unwrap();
45+
4146
// Create a list of valid arguments and sub-commands
4247
let matches = App::new(NAME)
4348
.about("Create a book in form of a static website from markdown files")

src/book/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl MDBook {
4242
pub fn new(root: &Path) -> MDBook {
4343

4444
if !root.exists() || !root.is_dir() {
45-
output!("{:?} No directory with that name", root);
45+
warn!("{:?} No directory with that name", root);
4646
}
4747

4848
MDBook {
@@ -116,7 +116,7 @@ impl MDBook {
116116

117117
if !self.root.exists() {
118118
fs::create_dir_all(&self.root).unwrap();
119-
output!("{:?} created", &self.root);
119+
info!("{:?} created", &self.root);
120120
}
121121

122122
{

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ extern crate rustc_serialize;
7373
extern crate handlebars;
7474
extern crate pulldown_cmark;
7575

76-
#[macro_use] pub mod macros;
76+
#[macro_use] extern crate log;
7777
pub mod book;
7878
mod parse;
7979
pub mod renderer;

src/macros.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/renderer/html_handlebars/hbs_renderer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl Renderer for HtmlHandlebars {
108108
// Write to file
109109
let mut file =
110110
try!(utils::fs::create_file(&book.get_dest().join(&ch.path).with_extension("html")));
111-
output!("[*] Creating {:?} ✓", &book.get_dest().join(&ch.path).with_extension("html"));
111+
info!("[*] Creating {:?} ✓", &book.get_dest().join(&ch.path).with_extension("html"));
112112

113113
try!(file.write_all(&rendered.into_bytes()));
114114

@@ -130,8 +130,8 @@ impl Renderer for HtmlHandlebars {
130130

131131
try!(index_file.write_all(content.as_bytes()));
132132

133-
output!("[*] Creating index.html from {:?} ✓",
134-
book.get_dest().join(&ch.path.with_extension("html")));
133+
info!("[*] Creating index.html from {:?} ✓",
134+
book.get_dest().join(&ch.path.with_extension("html")));
135135
index = false;
136136
}
137137
}
@@ -159,7 +159,7 @@ impl Renderer for HtmlHandlebars {
159159
let rendered = try!(handlebars.render("index", &data));
160160
let mut file = try!(utils::fs::create_file(&book.get_dest().join("print").with_extension("html")));
161161
try!(file.write_all(&rendered.into_bytes()));
162-
output!("[*] Creating print.html ✓");
162+
info!("[*] Creating print.html ✓");
163163

164164
// Copy static files (js, css, images, ...)
165165

src/renderer/html_handlebars/helpers/playpen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn render_playpen(s: &str, path: &Path) -> String {
2020

2121
// Check if the file exists
2222
if !playpen.rust_file.exists() || !playpen.rust_file.is_file() {
23-
output!("[-] No file exists for {{{{#playpen }}}}\n {}", playpen.rust_file.to_str().unwrap());
23+
warn!("[-] No file exists for {{{{#playpen }}}}\n {}", playpen.rust_file.to_str().unwrap());
2424
continue;
2525
}
2626

src/utils/fs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ pub fn copy_files_except_ext(from: &Path, to: &Path, recursive: bool, ext_blackl
150150
debug!("[*] creating path for file: {:?}",
151151
&to.join(entry.path().file_name().expect("a file should have a file name...")));
152152

153-
output!("[*] Copying file: {:?}\n to {:?}",
154-
entry.path(),
155-
&to.join(entry.path().file_name().expect("a file should have a file name...")));
153+
info!("[*] Copying file: {:?}\n to {:?}",
154+
entry.path(),
155+
&to.join(entry.path().file_name().expect("a file should have a file name...")));
156156
try!(fs::copy(entry.path(),
157157
&to.join(entry.path().file_name().expect("a file should have a file name..."))));
158158
}

0 commit comments

Comments
 (0)