Skip to content

Fix warnings and run cargo fmt #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions examples/proper.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
extern crate slog_stdlog;
extern crate slog_async;
extern crate slog_envlogger;
extern crate slog_term;
extern crate slog_scope;
extern crate slog_async;
extern crate slog_stdlog;
extern crate slog_term;

/// Import longer-name versions of macros only to not collide with legacy `log`
#[macro_use(slog_error, slog_info, slog_trace, slog_log, slog_o, slog_record,
slog_record_static, slog_b, slog_kv)]
#[macro_use(slog_error, slog_info, slog_trace, slog_o)]
extern crate slog;

use slog::Drain;
@@ -15,22 +14,20 @@ use slog::Drain;
extern crate log;

fn main() {
let drain =
slog_async::Async::default(
slog_envlogger::new(
slog_term::CompactFormat::new(
slog_term::TermDecorator::new()
.stderr().build()
).build().fuse()
));
let drain = slog_async::Async::default(slog_envlogger::new(
slog_term::CompactFormat::new(slog_term::TermDecorator::new().stderr().build())
.build()
.fuse(),
));

let root_logger = slog::Logger::root(drain.fuse(),
slog_o!("build" => "8jdkj2df", "version" => "0.1.5"));
let root_logger = slog::Logger::root(
drain.fuse(),
slog_o!("build" => "8jdkj2df", "version" => "0.1.5"),
);

slog_stdlog::init().unwrap();

slog_scope::scope(&root_logger, || {

slog_error!(root_logger, "slog error");
error!("log error");
slog_info!(root_logger, "slog info");
8 changes: 4 additions & 4 deletions examples/scopes.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
extern crate slog_stdlog;
extern crate slog_envlogger;
extern crate slog_scope;
extern crate slog_stdlog;

#[macro_use(o, kv)]
#[macro_use(o)]
extern crate slog;

#[macro_use]
@@ -15,7 +15,7 @@ fn main() {

slog_scope::scope(
&slog_scope::logger().new(o!("scope-extra-data" => "data")),
|| foo()
foo,
);

trace!("log trace");
@@ -27,7 +27,7 @@ fn foo() {
// scopes can be nested!
slog_scope::scope(
&slog_scope::logger().new(o!("even-more-scope-extra-data" => "data2")),
|| bar()
bar,
);
}

2 changes: 1 addition & 1 deletion examples/simple.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern crate slog_stdlog;
extern crate slog_envlogger;
extern crate slog_stdlog;

#[macro_use]
extern crate log;
253 changes: 151 additions & 102 deletions src/lib.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/regex.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ pub struct Filter {

impl Filter {
pub fn new(spec: &str) -> Result<Filter, String> {
match Regex::new(spec){
match Regex::new(spec) {
Ok(r) => Ok(Filter { inner: r }),
Err(e) => Err(e.to_string()),
}
4 changes: 3 additions & 1 deletion src/string.rs
Original file line number Diff line number Diff line change
@@ -6,7 +6,9 @@ pub struct Filter {

impl Filter {
pub fn new(spec: &str) -> Result<Filter, String> {
Ok(Filter { inner: spec.to_string() })
Ok(Filter {
inner: spec.to_string(),
})
}

pub fn is_match(&self, s: &str) -> bool {
16 changes: 11 additions & 5 deletions tests/regexp_filter.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#[macro_use] extern crate log;
#[macro_use]
extern crate log;
extern crate slog_envlogger;

use std::process;
use std::env;
use std::process;
use std::str;

fn main() {
@@ -14,7 +15,7 @@ fn main() {
}

fn child_main() {
let _guard =slog_envlogger::init().unwrap();
let _guard = slog_envlogger::init().unwrap();
info!("XYZ Message");
}

@@ -25,7 +26,9 @@ fn run_child(rust_log: String) -> bool {
.env("RUST_LOG", rust_log)
.output()
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
str::from_utf8(out.stderr.as_ref()).unwrap().contains("XYZ Message")
str::from_utf8(out.stderr.as_ref())
.unwrap()
.contains("XYZ Message")
}

fn assert_message_printed(rust_log: &str) {
@@ -36,7 +39,10 @@ fn assert_message_printed(rust_log: &str) {

fn assert_message_not_printed(rust_log: &str) {
if run_child(rust_log.to_string()) {
panic!("RUST_LOG={} should not allow the test log message", rust_log)
panic!(
"RUST_LOG={} should not allow the test log message",
rust_log
)
}
}