Merge pull request #517 from Michael-F-Bryan/update-deps

Update dependency versions and made logging more readable
This commit is contained in:
Michael Bryan 2017-12-30 19:05:46 +08:00 committed by GitHub
commit bd134fbaa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 20 deletions

View File

@ -16,15 +16,16 @@ exclude = [
[dependencies]
clap = "2.24"
chrono = "0.4"
handlebars = "0.29"
serde = "1.0"
serde_derive = "1.0"
error-chain = "0.11.0"
serde_json = "1.0"
pulldown-cmark = "0.1"
lazy_static = "0.2"
log = "0.3"
env_logger = "0.4.0"
lazy_static = "1.0"
log = "0.4"
env_logger = "0.5.0-rc.1"
toml = "0.4"
memchr = "2.0.1"
open = "1.1"
@ -37,8 +38,8 @@ time = { version = "0.1.34", optional = true }
crossbeam = { version = "0.3", optional = true }
# Serve feature
iron = { version = "0.5", optional = true }
staticfile = { version = "0.4", optional = true }
iron = { version = "0.6", optional = true }
staticfile = { version = "0.5", optional = true }
ws = { version = "0.7", optional = true}
[build-dependencies]
@ -47,7 +48,7 @@ error-chain = "0.11"
[dev-dependencies]
select = "0.4"
pretty_assertions = "0.4"
walkdir = "1.0"
walkdir = "2.0"
[features]
default = ["output", "watch", "serve"]

View File

@ -1,5 +1,6 @@
#[macro_use]
extern crate clap;
extern crate chrono;
extern crate env_logger;
extern crate error_chain;
extern crate log;
@ -9,9 +10,11 @@ extern crate open;
use std::env;
use std::ffi::OsStr;
use std::path::{Path, PathBuf};
use std::io::Write;
use clap::{App, AppSettings, ArgMatches};
use log::{LogLevelFilter, LogRecord};
use env_logger::LogBuilder;
use chrono::Local;
use log::LevelFilter;
use env_logger::Builder;
use error_chain::ChainedError;
pub mod build;
@ -67,19 +70,24 @@ fn main() {
}
fn init_logger() {
let format = |record: &LogRecord| {
let module_path = record.location().module_path();
format!("{}:{}: {}", record.level(), module_path, record.args())
};
let mut builder = Builder::new();
let mut builder = LogBuilder::new();
builder.format(format).filter(None, LogLevelFilter::Info);
builder.format(|formatter, record| {
writeln!(formatter, "{} [{}] ({}): {}",
Local::now().format("%Y-%m-%d %H:%M:%S"),
record.level(),
record.target(),
record.args())
});
if let Ok(var) = env::var("RUST_LOG") {
builder.parse(&var);
} else {
// if no RUST_LOG provided, default to logging at the Info level
builder.filter(None, LevelFilter::Info);
}
builder.init().unwrap();
builder.init();
}
fn get_book_dir(args: &ArgMatches) -> PathBuf {

View File

@ -64,7 +64,7 @@ impl MDBook {
Config::default()
};
if log_enabled!(::log::LogLevel::Trace) {
if log_enabled!(::log::Level::Trace) {
for line in format!("Config: {:#?}", config).lines() {
trace!("{}", line);
}

View File

@ -689,8 +689,6 @@ mod tests {
/// [example]: https://github.com/rust-lang/book/blob/2c942dc094f4ddcdc7aba7564f80782801197c99/second-edition/src/SUMMARY.md#basic-rust-literacy
#[test]
fn can_have_a_subheader_between_nested_items() {
extern crate env_logger;
env_logger::init().ok();
let src = "- [First](./first.md)\n\n## Subheading\n\n- [Second](./second.md)\n";
let should_be = vec![
SummaryItem::Link(Link {

View File

@ -14,7 +14,7 @@ macro_rules! summary_md_test {
($name:ident, $filename:expr) => {
#[test]
fn $name() {
env_logger::init().ok();
env_logger::try_init().ok();
let filename = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("tests")

View File

@ -11,7 +11,7 @@ use dummy_book::{assert_contains_strings, DummyBook};
use std::fs;
use std::path::Path;
use std::ffi::OsStr;
use walkdir::{DirEntry, WalkDir, WalkDirIterator};
use walkdir::{DirEntry, WalkDir};
use select::document::Document;
use select::predicate::{Class, Name, Predicate};
use mdbook::errors::*;