mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-16 09:08:37 +01:00
Do not call init_logger from inside watch.
And move init_logger to main.rs for future use.
This commit is contained in:
parent
6f6fb0ceb2
commit
ebd5ec084f
2 changed files with 16 additions and 16 deletions
16
src/main.rs
16
src/main.rs
|
@ -1,3 +1,5 @@
|
|||
use std::io::Write;
|
||||
|
||||
extern crate watchexec;
|
||||
|
||||
use watchexec::{cli, error, run};
|
||||
|
@ -5,3 +7,17 @@ use watchexec::{cli, error, run};
|
|||
fn main() -> error::Result<()> {
|
||||
run(cli::get_args()?)
|
||||
}
|
||||
|
||||
fn init_logger(debug: bool) {
|
||||
let mut log_builder = env_logger::Builder::new();
|
||||
let level = if debug {
|
||||
log::LevelFilter::Debug
|
||||
} else {
|
||||
log::LevelFilter::Warn
|
||||
};
|
||||
|
||||
log_builder
|
||||
.format(|buf, r| writeln!(buf, "*** {}", r.args()))
|
||||
.filter(None, level)
|
||||
.init();
|
||||
}
|
||||
|
|
16
src/run.rs
16
src/run.rs
|
@ -10,7 +10,6 @@ use crate::watcher::{Event, Watcher};
|
|||
use std::{
|
||||
collections::HashMap,
|
||||
fs::canonicalize,
|
||||
io::Write,
|
||||
sync::{
|
||||
mpsc::{channel, Receiver},
|
||||
Arc, RwLock,
|
||||
|
@ -18,20 +17,6 @@ use std::{
|
|||
time::Duration,
|
||||
};
|
||||
|
||||
fn init_logger(debug: bool) {
|
||||
let mut log_builder = env_logger::Builder::new();
|
||||
let level = if debug {
|
||||
log::LevelFilter::Debug
|
||||
} else {
|
||||
log::LevelFilter::Warn
|
||||
};
|
||||
|
||||
log_builder
|
||||
.format(|buf, r| writeln!(buf, "*** {}", r.args()))
|
||||
.filter(None, level)
|
||||
.init();
|
||||
}
|
||||
|
||||
pub trait Handler {
|
||||
/// Called through a manual request, such as an initial run.
|
||||
///
|
||||
|
@ -76,7 +61,6 @@ where
|
|||
H: Handler,
|
||||
{
|
||||
let args = handler.args();
|
||||
init_logger(args.debug);
|
||||
|
||||
let mut paths = vec![];
|
||||
for path in &args.paths {
|
||||
|
|
Loading…
Reference in a new issue