1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#![feature(macro_reexport)]
#![allow(unused_imports)]
pub extern crate chrono;
pub extern crate console;
pub extern crate ctrlc;
pub extern crate dialoguer;
#[macro_reexport(format_err)]
#[macro_use]
pub extern crate failure;
#[macro_reexport(Fail)]
#[macro_use] #[no_link]
pub extern crate failure_derive;
#[cfg(feature="logging")]
pub extern crate fern;
pub extern crate indicatif;
#[macro_reexport(iproduct, izip)]
#[macro_use]
pub extern crate itertools;
#[macro_reexport(lazy_static)]
#[macro_use]
pub extern crate lazy_static;
pub extern crate libc;
#[cfg(feature="logging")]
extern crate log;
#[macro_reexport(hashmap, hashset, btreemap, btreeset)]
#[macro_use] #[no_link]
pub extern crate maplit;
pub extern crate rand;
pub extern crate rayon;
pub extern crate regex;
pub extern crate reqwest;
pub extern crate semver;
pub extern crate serde;
#[macro_reexport(Serialize, Deserialize)]
#[macro_use] #[no_link]
pub extern crate serde_derive;
pub extern crate serde_json;
pub extern crate serde_yaml;
pub extern crate shellexpand;
pub extern crate std_prelude;
pub extern crate structopt;
#[macro_reexport(StructOpt)]
#[macro_use] #[no_link]
pub extern crate structopt_derive;
pub extern crate tabwriter;
pub extern crate tar;
pub extern crate tempdir;
pub extern crate toml;
pub extern crate walkdir;
pub mod prelude;
pub mod term;
#[cfg(feature="logging")]
pub fn init_log(
verbosity: u64,
stderr: bool,
logfile: Option<&::std::path::Path>)
{
use log::LogLevelFilter;
let level = match verbosity {
0 => return,
1 => LogLevelFilter::Error,
2 => LogLevelFilter::Info,
3 => LogLevelFilter::Debug,
_ => LogLevelFilter::Trace,
};
let dispatch = ::fern::Dispatch::new()
.format(|out, message, record| {
out.finish(format_args!(
"{: <5} [{} {}] {}",
record.level(),
::chrono::Local::now().format("%Y-%m-%d %H:%M:%S"),
record.target(),
message
))
})
.level(level);
let dispatch = if stderr {
dispatch.chain(std::io::stderr())
} else {
dispatch
};
let dispatch = if let Some(p) = logfile {
let f = ::fern::log_file(p)
.expect(&format!("failed to open logfile: {:?}", p));
dispatch.chain(f)
} else {
dispatch
};
dispatch.apply().expect("failed to set logger, was it already initialized?");
}