Colorful logging in examples

This commit is contained in:
Benjamin Saunders
2019-06-23 19:24:10 -07:00
committed by Dirkjan Ochtman
parent f112e25e53
commit 747d5a263b
3 changed files with 10 additions and 5 deletions
+3 -1
View File
@@ -33,11 +33,13 @@ struct Opt {
fn main() {
let opt = Opt::from_args();
let code = {
let decorator = slog_term::PlainSyncDecorator::new(std::io::stderr());
let decorator = slog_term::TermDecorator::new().stderr().build();
let drain = slog_term::FullFormat::new(decorator)
.use_original_order()
.build()
.fuse();
// We use a mutex-protected drain for simplicity; this tool is single-threaded anyway.
let drain = std::sync::Mutex::new(drain).fuse();
if let Err(e) = run(Logger::root(drain, o!()), opt) {
eprintln!("ERROR: {}", e);
1
+3 -1
View File
@@ -46,11 +46,13 @@ struct Opt {
fn main() {
let opt = Opt::from_args();
let code = {
let decorator = slog_term::PlainSyncDecorator::new(std::io::stderr());
let decorator = slog_term::TermDecorator::new().stderr().build();
let drain = slog_term::FullFormat::new(decorator)
.use_original_order()
.build()
.fuse();
// We use a mutex-protected drain for simplicity; this example is single-threaded anyway.
let drain = std::sync::Mutex::new(drain).fuse();
if let Err(e) = run(Logger::root(drain, o!()), opt) {
eprintln!("ERROR: {}", e);
1
+4 -3
View File
@@ -69,11 +69,12 @@ struct Opt {
fn main() {
let opt = Opt::from_args();
let code = {
let decorator = slog_term::PlainSyncDecorator::new(std::io::stderr());
let decorator = slog_term::TermDecorator::new().stderr().build();
let drain = slog_term::FullFormat::new(decorator)
.use_original_order()
.build()
.fuse();
.build();
// We use a mutex-protected drain for simplicity; this example is single-threaded anyway.
let drain = std::sync::Mutex::new(drain).fuse();
if let Err(e) = run(Logger::root(drain, o!()), opt) {
eprintln!("ERROR: {}", e.pretty());
1