extern crate chrono;
extern crate env_logger;
extern crate log;

use self::chrono::prelude::*;

use self::env_logger::fmt::Formatter;
use self::env_logger::Builder;
use self::log::{LevelFilter, Record};
use std::io::Write;
use std::thread;

pub fn setup_logger(log_thread: bool, rust_log: Option<&str>) {
    let output_format = move |formatter: &mut Formatter, record: &Record| {
        let thread_name = if log_thread {
            format!("(t: {}) ", thread::current().name().unwrap_or("unknown"))
        } else {
            "".to_string()
        };

        let local_time: DateTime<Local> = Local::now();
        let time_str = local_time.format("%H:%M:%S%.3f").to_string();
        write!(
            formatter,
            "{} {}{} - {} - {}\n",
            time_str,
            thread_name,
            record.level(),
            record.target(),
            record.args()
        )
    };

    let mut builder = Builder::new();
    builder
        .format(output_format)
        .filter(None, LevelFilter::Info);

    rust_log.map(|conf| builder.parse_filters(conf));

    builder.init();
}

#[allow(dead_code)]
fn main() {
    println!("This is not an example");
}

extern crate chrono;
extern crate env_logger;
extern crate log;

use self::chrono::prelude::*;

use self::env_logger::fmt::Formatter;
use self::env_logger::Builder;
use self::log::{LevelFilter, Record};
use std::io::Write;
use std::thread;

pub fn setup_logger(log_thread: bool, rust_log: Option<&str>) {
    let output_format = move |formatter: &mut Formatter, record: &Record| {
        let thread_name = if log_thread {
            format!("(t: {}) ", thread::current().name().unwrap_or("unknown"))
        } else {
            "".to_string()
        };

        let local_time: DateTime<Local> = Local::now();
        let time_str = local_time.format("%H:%M:%S%.3f").to_string();
        write!(
            formatter,
            "{} {}{} - {} - {}",
            time_str,
            thread_name,
            record.level(),
            record.target(),
            record.args()
        )
    };

    let mut builder = Builder::new();
    builder
        .format(output_format)
        .filter(None, LevelFilter::Info);

    rust_log.map(|conf| builder.parse_filters(conf));

    builder.init();
}

#[allow(dead_code)]
fn main() {
    println!("This is not an example");
}

--- 
+++ 
@@ -22,7 +22,7 @@
         let time_str = local_time.format("%H:%M:%S%.3f").to_string();
         write!(
             formatter,
-            "{} {}{} - {} - {}",
+            "{} {}{} - {} - {}\n",
             time_str,
             thread_name,
             record.level(),
Include newline in example log output

The example output was previously unreadable, since the log format
didn't include a newline. Perhaps related to the env_logger bump.
