зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1443257 - Update log crate from 0.3.8 to 0.3.9. r=ted
MozReview-Commit-ID: DMzMun9EgnG --HG-- rename : third_party/rust/log-0.3.8/LICENSE-APACHE => third_party/rust/log-0.3.9/LICENSE-APACHE rename : third_party/rust/log-0.3.8/LICENSE-MIT => third_party/rust/log-0.3.9/LICENSE-MIT rename : third_party/rust/log-0.3.8/appveyor.yml => third_party/rust/log-0.3.9/appveyor.yml extra : amend_source : aa43f61701d7b5b97cac89faaa4e66c67035c4e1
This commit is contained in:
Родитель
f61f2a79b7
Коммит
134bbc1272
|
@ -59,7 +59,7 @@ dependencies = [
|
|||
"futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memmap 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -79,7 +79,7 @@ dependencies = [
|
|||
"futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tokio-core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tokio-uds 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -95,7 +95,7 @@ dependencies = [
|
|||
"futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazycell 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tokio-core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tokio-uds 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -551,7 +551,7 @@ name = "env_logger"
|
|||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -706,7 +706,7 @@ dependencies = [
|
|||
"cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"malloc_size_of 0.0.1",
|
||||
"nsstring 0.1.0",
|
||||
"parking_lot 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -747,7 +747,7 @@ dependencies = [
|
|||
"encoding_c 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding_glue 0.1.0",
|
||||
"geckoservo 0.0.1",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mp4parse_capi 0.10.0",
|
||||
"netwerk_helper 0.0.1",
|
||||
"nserror 0.1.0",
|
||||
|
@ -766,7 +766,7 @@ version = "0.8.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"khronos_api 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -812,7 +812,7 @@ dependencies = [
|
|||
"base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -869,7 +869,7 @@ dependencies = [
|
|||
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mozjs_sys 0.0.0",
|
||||
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -953,8 +953,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.3.8"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
|
@ -1022,7 +1025,7 @@ name = "mime"
|
|||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1054,7 +1057,7 @@ dependencies = [
|
|||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazycell 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1534,7 +1537,7 @@ dependencies = [
|
|||
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1651,7 +1654,7 @@ dependencies = [
|
|||
"itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"malloc_size_of 0.0.1",
|
||||
"malloc_size_of_derive 0.0.1",
|
||||
"matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1715,7 +1718,7 @@ dependencies = [
|
|||
"euclid 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"geckoservo 0.0.1",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"malloc_size_of 0.0.1",
|
||||
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.19.0",
|
||||
|
@ -1841,7 +1844,7 @@ dependencies = [
|
|||
"bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mio 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1855,7 +1858,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
dependencies = [
|
||||
"bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1867,7 +1870,7 @@ dependencies = [
|
|||
"futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mio 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mio-uds 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tokio-core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1898,7 +1901,7 @@ dependencies = [
|
|||
"core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libudev 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"runloop 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2304,7 +2307,7 @@ dependencies = [
|
|||
"checksum libloading 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "be99f814beb3e9503a786a592c909692bb6d4fc5a695f6ed7987223acfbd5194"
|
||||
"checksum libudev 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea626d3bdf40a1c5aee3bcd4f40826970cae8d80a8fec934c82a63840094dcfe"
|
||||
"checksum libz-sys 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "3fdd64ef8ee652185674455c1d450b83cbc8ad895625d543b5324d923f82e4d8"
|
||||
"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"
|
||||
"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
|
||||
"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2"
|
||||
"checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376"
|
||||
"checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
{"files":{".travis.yml":"985cf95c79f32c65766927fd6ef5079f8c14f235ddb4213e6410d90a86a95811","Cargo.toml":"0a4a756f7ef47f5dfa221a173b21f9ec496b448aafcd9bde08d9d16935b55007","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"aa8356455efcc3d49f66e7fa394eac292c9158164dff074e32c699b64891cb4b","appveyor.yml":"c61473b8c780ad2626282ce2b2ba0ef278082b6afe151a62ff419f33eaf90221","src/lib.rs":"75b44acfc9627b821cd725649db07693a43b2e44b2fac19b79354c6d950c4038","src/macros.rs":"3953610da3ee2dc393262b753f2406d1864a1cbd74d2bd20d279e09aabfe7131","tests/filters.rs":"cc61ed41a6cd77e5aef91cc8c76216b492d8de34f00635254f3835a3d964ce22"},"package":"880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"}
|
|
@ -1,76 +0,0 @@
|
|||
#[macro_use] extern crate log;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
use log::{LogLevel, LogLevelFilter, Log, LogRecord, LogMetadata};
|
||||
use log::MaxLogLevelFilter;
|
||||
|
||||
#[cfg(feature = "use_std")]
|
||||
use log::set_logger;
|
||||
#[cfg(not(feature = "use_std"))]
|
||||
fn set_logger<M>(make_logger: M) -> Result<(), log::SetLoggerError>
|
||||
where M: FnOnce(MaxLogLevelFilter) -> Box<Log> {
|
||||
unsafe {
|
||||
log::set_logger_raw(|x| std::mem::transmute(make_logger(x)))
|
||||
}
|
||||
}
|
||||
|
||||
struct State {
|
||||
last_log: Mutex<Option<LogLevel>>,
|
||||
filter: MaxLogLevelFilter,
|
||||
}
|
||||
|
||||
struct Logger(Arc<State>);
|
||||
|
||||
impl Log for Logger {
|
||||
fn enabled(&self, _: &LogMetadata) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn log(&self, record: &LogRecord) {
|
||||
*self.0.last_log.lock().unwrap() = Some(record.level());
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut a = None;
|
||||
set_logger(|max| {
|
||||
let me = Arc::new(State {
|
||||
last_log: Mutex::new(None),
|
||||
filter: max,
|
||||
});
|
||||
a = Some(me.clone());
|
||||
Box::new(Logger(me))
|
||||
}).unwrap();
|
||||
let a = a.unwrap();
|
||||
|
||||
test(&a, LogLevelFilter::Off);
|
||||
test(&a, LogLevelFilter::Error);
|
||||
test(&a, LogLevelFilter::Warn);
|
||||
test(&a, LogLevelFilter::Info);
|
||||
test(&a, LogLevelFilter::Debug);
|
||||
test(&a, LogLevelFilter::Trace);
|
||||
}
|
||||
|
||||
fn test(a: &State, filter: LogLevelFilter) {
|
||||
a.filter.set(filter);
|
||||
error!("");
|
||||
last(&a, t(LogLevel::Error, filter));
|
||||
warn!("");
|
||||
last(&a, t(LogLevel::Warn, filter));
|
||||
info!("");
|
||||
last(&a, t(LogLevel::Info, filter));
|
||||
debug!("");
|
||||
last(&a, t(LogLevel::Debug, filter));
|
||||
trace!("");
|
||||
last(&a, t(LogLevel::Trace, filter));
|
||||
|
||||
fn t(lvl: LogLevel, filter: LogLevelFilter) -> Option<LogLevel> {
|
||||
if lvl <= filter {Some(lvl)} else {None}
|
||||
}
|
||||
}
|
||||
|
||||
fn last(state: &State, expected: Option<LogLevel>) {
|
||||
let mut lvl = state.last_log.lock().unwrap();
|
||||
assert_eq!(*lvl, expected);
|
||||
*lvl = None;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
{"files":{".travis.yml":"2cdde67eec211928d7e667e5ade109cdf0f74c3417c47cc48905929c5c165230","Cargo.toml":"827b8cdf64e9652b178d6033fdcb4fc04a1382edf67ce4f2c6dce39943349f10","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"7c831cff45cfd33333cc246815dccb25bfa0b981053656e707828fe3f25151da","appveyor.yml":"c61473b8c780ad2626282ce2b2ba0ef278082b6afe151a62ff419f33eaf90221","src/lib.rs":"8238bde9046b1b4a0d21b5ae9029abd672a7d314581b1fd8d0890b2a3052d443","src/macros.rs":"9068d69d32e989ac273ce73659125d31cf4a166076eefdad74dfbdf9506cf9c4"},"package":"e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"}
|
|
@ -12,6 +12,7 @@ script:
|
|||
- ([ $TRAVIS_RUST_VERSION != nightly ] || cargo build --verbose --features nightly)
|
||||
- cargo test --verbose
|
||||
- ([ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose --no-default-features)
|
||||
- cargo test --verbose --manifest-path log-test/Cargo.toml
|
||||
- cargo test --verbose --manifest-path env/Cargo.toml
|
||||
- cargo test --verbose --manifest-path env/Cargo.toml --no-default-features
|
||||
- cargo run --verbose --manifest-path tests/max_level_features/Cargo.toml
|
|
@ -12,38 +12,34 @@
|
|||
|
||||
[package]
|
||||
name = "log"
|
||||
version = "0.3.8"
|
||||
version = "0.3.9"
|
||||
authors = ["The Rust Project Developers"]
|
||||
description = "A lightweight logging facade for Rust\n"
|
||||
homepage = "https://github.com/rust-lang/log"
|
||||
documentation = "https://docs.rs/log"
|
||||
documentation = "https://doc.rust-lang.org/log"
|
||||
readme = "README.md"
|
||||
categories = ["development-tools::debugging"]
|
||||
license = "MIT/Apache-2.0"
|
||||
repository = "https://github.com/rust-lang/log"
|
||||
|
||||
[[test]]
|
||||
name = "filters"
|
||||
harness = false
|
||||
[lib]
|
||||
doctest = false
|
||||
[dependencies.log]
|
||||
version = "0.4"
|
||||
|
||||
[features]
|
||||
max_level_info = []
|
||||
nightly = []
|
||||
max_level_warn = []
|
||||
release_max_level_debug = []
|
||||
release_max_level_info = []
|
||||
release_max_level_off = []
|
||||
release_max_level_error = []
|
||||
max_level_debug = []
|
||||
release_max_level_warn = []
|
||||
use_std = []
|
||||
max_level_off = []
|
||||
max_level_trace = []
|
||||
release_max_level_trace = []
|
||||
max_level_error = []
|
||||
default = ["use_std"]
|
||||
[badges.appveyor]
|
||||
repository = "alexcrichton/log"
|
||||
|
||||
[badges.travis-ci]
|
||||
repository = "rust-lang-nursery/log"
|
||||
max_level_debug = ["log/max_level_debug"]
|
||||
max_level_error = ["log/max_level_error"]
|
||||
max_level_info = ["log/max_level_info"]
|
||||
max_level_off = ["log/max_level_off"]
|
||||
max_level_trace = ["log/max_level_trace"]
|
||||
max_level_warn = ["log/max_level_warn"]
|
||||
nightly = []
|
||||
release_max_level_debug = ["log/release_max_level_debug"]
|
||||
release_max_level_error = ["log/release_max_level_error"]
|
||||
release_max_level_info = ["log/release_max_level_info"]
|
||||
release_max_level_off = ["log/release_max_level_off"]
|
||||
release_max_level_trace = ["log/release_max_level_trace"]
|
||||
release_max_level_warn = ["log/release_max_level_warn"]
|
||||
use_std = ["log/std"]
|
|
@ -158,20 +158,3 @@ test tests::it_adds_one ... ok
|
|||
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
||||
```
|
||||
|
||||
## Configuring log target
|
||||
|
||||
By default, `env_logger` logs to stderr. If you want to log to stdout instead,
|
||||
you can use the `LogBuilder` to change the log target:
|
||||
|
||||
```rust
|
||||
use std::env;
|
||||
use env_logger::{LogBuilder, LogTarget};
|
||||
|
||||
let mut builder = LogBuilder::new();
|
||||
builder.target(LogTarget::Stdout);
|
||||
if env::var("RUST_LOG").is_ok() {
|
||||
builder.parse(&env::var("RUST_LOG").unwrap());
|
||||
}
|
||||
builder.init().unwrap();
|
||||
```
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
//! A lightweight logging facade.
|
||||
//!
|
||||
//! The `log` crate provides a single logging API that abstracts over the
|
||||
//! A logging facade provides a single logging API that abstracts over the
|
||||
//! actual logging implementation. Libraries can use the logging API provided
|
||||
//! by this crate, and the consumer of those libraries can choose the logging
|
||||
//! framework that is most suitable for its use case.
|
||||
|
@ -19,10 +19,11 @@
|
|||
//! implementation that ignores all log messages. The overhead in this case
|
||||
//! is very small - just an integer load, comparison and jump.
|
||||
//!
|
||||
//! A log request consists of a _target_, a _level_, and a _body_. A target is a
|
||||
//! string which defaults to the module path of the location of the log request,
|
||||
//! though that default may be overridden. Logger implementations typically use
|
||||
//! the target to filter requests based on some user configuration.
|
||||
//! A log request consists of a target, a level, and a body. A target is a
|
||||
//! string which defaults to the module path of the location of the log
|
||||
//! request, though that default may be overridden. Logger implementations
|
||||
//! typically use the target to filter requests based on some user
|
||||
//! configuration.
|
||||
//!
|
||||
//! # Use
|
||||
//!
|
||||
|
@ -78,25 +79,21 @@
|
|||
//! ```rust,ignore
|
||||
//! #[macro_use]
|
||||
//! extern crate log;
|
||||
//! extern crate env_logger;
|
||||
//! extern crate my_logger;
|
||||
//!
|
||||
//! fn main() {
|
||||
//! // Select env_logger, one possible logger implementation
|
||||
//! // (see https://doc.rust-lang.org/log/env_logger/index.html)
|
||||
//! env_logger::init().unwrap();
|
||||
//!
|
||||
//! my_logger::init();
|
||||
//!
|
||||
//! info!("starting up");
|
||||
//! error!("error: {}", 404);
|
||||
//!
|
||||
//!
|
||||
//! // ...
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! # Logger implementations
|
||||
//!
|
||||
//! Loggers implement the [`Log`] trait. Here's a very basic example that simply
|
||||
//! logs all messages at the [`Error`][level_link], [`Warn`][level_link] or
|
||||
//! [`Info`][level_link] levels to stdout:
|
||||
//! Loggers implement the `Log` trait. Here's a very basic example that simply
|
||||
//! logs all messages at the `Error`, `Warn` or `Info` levels to stdout:
|
||||
//!
|
||||
//! ```rust
|
||||
//! extern crate log;
|
||||
|
@ -120,16 +117,15 @@
|
|||
//! # fn main() {}
|
||||
//! ```
|
||||
//!
|
||||
//! Loggers are installed by calling the [`set_logger`] function. It takes a
|
||||
//! closure which is provided a [`MaxLogLevelFilter`] token and returns a
|
||||
//! [`Log`] trait object. The [`MaxLogLevelFilter`] token controls the global
|
||||
//! maximum log level. The logging facade uses this as an optimization to
|
||||
//! improve performance of log messages at levels that are disabled. In the
|
||||
//! case of our example logger, we'll want to set the maximum log level to
|
||||
//! [`Info`][level_link], since we ignore any [`Debug`][level_link] or
|
||||
//! [`Trace`][level_link] level log messages. A logging framework should
|
||||
//! provide a function that wraps a call to [`set_logger`], handling
|
||||
//! initialization of the logger:
|
||||
//! Loggers are installed by calling the `set_logger` function. It takes a
|
||||
//! closure which is provided a `MaxLogLevel` token and returns a `Log` trait
|
||||
//! object. The `MaxLogLevel` token controls the global maximum log level. The
|
||||
//! logging facade uses this as an optimization to improve performance of log
|
||||
//! messages at levels that are disabled. In the case of our example logger,
|
||||
//! we'll want to set the maximum log level to `Info`, since we ignore any
|
||||
//! `Debug` or `Trace` level log messages. A logging framework should provide a
|
||||
//! function that wraps a call to `set_logger`, handling initialization of the
|
||||
//! logger:
|
||||
//!
|
||||
//! ```rust
|
||||
//! # extern crate log;
|
||||
|
@ -154,8 +150,8 @@
|
|||
//! To use the `log` crate without depending on `libstd`, you need to specify
|
||||
//! `default-features = false` when specifying the dependency in `Cargo.toml`.
|
||||
//! This makes no difference to libraries using `log` since the logging API
|
||||
//! remains the same. However executables will need to use the [`set_logger_raw`]
|
||||
//! function to initialize a logger and the [`shutdown_logger_raw`] function to
|
||||
//! remains the same. However executables will need to use the `set_logger_raw`
|
||||
//! function to initialize a logger and the `shutdown_logger_raw` function to
|
||||
//! shut down the global logger before exiting:
|
||||
//!
|
||||
//! ```rust
|
||||
|
@ -187,19 +183,11 @@
|
|||
//! })
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! [`Log`]: trait.Log.html
|
||||
//! [level_link]: enum.LogLevel.html
|
||||
//! [`set_logger`]: fn.set_logger.html
|
||||
//! [`MaxLogLevelFilter`]: struct.MaxLogLevelFilter.html
|
||||
//! [`set_logger_raw`]: fn.set_logger_raw.html
|
||||
//! [`shutdown_logger_raw`]: fn.shutdown_logger_raw.html
|
||||
|
||||
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "https://doc.rust-lang.org/log/")]
|
||||
#![warn(missing_docs)]
|
||||
#![deny(missing_debug_implementations)]
|
||||
#![cfg_attr(feature = "nightly", feature(panic_handler))]
|
||||
|
||||
#![cfg_attr(not(feature = "use_std"), no_std)]
|
||||
|
@ -211,6 +199,7 @@
|
|||
|
||||
#[cfg(not(feature = "use_std"))]
|
||||
extern crate core as std;
|
||||
extern crate log;
|
||||
|
||||
use std::cmp;
|
||||
#[cfg(feature = "use_std")]
|
||||
|
@ -247,23 +236,17 @@ static mut LOGGER: *const Log = &NopLogger;
|
|||
static STATE: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
static REFCOUNT: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
|
||||
const UNINITIALIZED: usize = 0;
|
||||
const INITIALIZING: usize = 1;
|
||||
const INITIALIZED: usize = 2;
|
||||
|
||||
static MAX_LOG_LEVEL_FILTER: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
|
||||
static LOG_LEVEL_NAMES: [&'static str; 6] = ["OFF", "ERROR", "WARN", "INFO",
|
||||
"DEBUG", "TRACE"];
|
||||
|
||||
/// An enum representing the available verbosity levels of the logging framework.
|
||||
/// An enum representing the available verbosity levels of the logging framework
|
||||
///
|
||||
/// Typical usage includes: checking if a certain `LogLevel` is enabled with
|
||||
/// [`log_enabled!`](macro.log_enabled.html), specifying the `LogLevel` of
|
||||
/// [`log!`](macro.log.html), and comparing a `LogLevel` directly to a
|
||||
/// [`LogLevelFilter`](enum.LogLevelFilter.html).
|
||||
/// A `LogLevel` may be compared directly to a `LogLevelFilter`.
|
||||
#[repr(usize)]
|
||||
#[derive(Copy, Eq, Debug, Hash)]
|
||||
#[derive(Copy, Eq, Debug)]
|
||||
pub enum LogLevel {
|
||||
/// The "error" level.
|
||||
///
|
||||
|
@ -385,6 +368,26 @@ impl LogLevel {
|
|||
}
|
||||
}
|
||||
|
||||
fn from_new(level: log::Level) -> LogLevel {
|
||||
match level {
|
||||
log::Level::Error => LogLevel::Error,
|
||||
log::Level::Warn => LogLevel::Warn,
|
||||
log::Level::Info => LogLevel::Info,
|
||||
log::Level::Debug => LogLevel::Debug,
|
||||
log::Level::Trace => LogLevel::Trace,
|
||||
}
|
||||
}
|
||||
|
||||
fn to_new(&self) -> log::Level {
|
||||
match *self {
|
||||
LogLevel::Error => log::Level::Error,
|
||||
LogLevel::Warn => log::Level::Warn,
|
||||
LogLevel::Info => log::Level::Info,
|
||||
LogLevel::Debug => log::Level::Debug,
|
||||
LogLevel::Trace => log::Level::Trace,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the most verbose logging level.
|
||||
#[inline]
|
||||
pub fn max() -> LogLevel {
|
||||
|
@ -401,13 +404,9 @@ impl LogLevel {
|
|||
/// An enum representing the available verbosity level filters of the logging
|
||||
/// framework.
|
||||
///
|
||||
/// A `LogLevelFilter` may be compared directly to a [`LogLevel`](enum.LogLevel.html).
|
||||
/// Use this type to [`get()`](struct.MaxLogLevelFilter.html#method.get) and
|
||||
/// [`set()`](struct.MaxLogLevelFilter.html#method.set) the
|
||||
/// [`MaxLogLevelFilter`](struct.MaxLogLevelFilter.html), or to match with the getter
|
||||
/// [`max_log_level()`](fn.max_log_level.html).
|
||||
/// A `LogLevelFilter` may be compared directly to a `LogLevel`.
|
||||
#[repr(usize)]
|
||||
#[derive(Copy, Eq, Debug, Hash)]
|
||||
#[derive(Copy, Eq, Debug)]
|
||||
pub enum LogLevelFilter {
|
||||
/// A level lower than all log levels.
|
||||
Off,
|
||||
|
@ -494,6 +493,29 @@ impl LogLevelFilter {
|
|||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
fn from_new(filter: log::LevelFilter) -> LogLevelFilter {
|
||||
match filter {
|
||||
log::LevelFilter::Off => LogLevelFilter::Off,
|
||||
log::LevelFilter::Error => LogLevelFilter::Error,
|
||||
log::LevelFilter::Warn => LogLevelFilter::Warn,
|
||||
log::LevelFilter::Info => LogLevelFilter::Info,
|
||||
log::LevelFilter::Debug => LogLevelFilter::Debug,
|
||||
log::LevelFilter::Trace => LogLevelFilter::Trace,
|
||||
}
|
||||
}
|
||||
|
||||
fn to_new(&self) -> log::LevelFilter {
|
||||
match *self {
|
||||
LogLevelFilter::Off => log::LevelFilter::Off,
|
||||
LogLevelFilter::Error => log::LevelFilter::Error,
|
||||
LogLevelFilter::Warn => log::LevelFilter::Warn,
|
||||
LogLevelFilter::Info => log::LevelFilter::Info,
|
||||
LogLevelFilter::Debug => log::LevelFilter::Debug,
|
||||
LogLevelFilter::Trace => log::LevelFilter::Trace,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the most verbose logging level filter.
|
||||
#[inline]
|
||||
pub fn max() -> LogLevelFilter {
|
||||
|
@ -509,12 +531,7 @@ impl LogLevelFilter {
|
|||
}
|
||||
}
|
||||
|
||||
/// The "payload" of a log message. This structure is primarily used as a
|
||||
/// parameter in the [`log`] method of the [`Log`] trait.
|
||||
///
|
||||
/// [`log`]: trait.Log.html#tymethod.log
|
||||
/// [`Log`]: trait.Log.html
|
||||
#[derive(Debug)]
|
||||
/// The "payload" of a log message.
|
||||
pub struct LogRecord<'a> {
|
||||
metadata: LogMetadata<'a>,
|
||||
location: &'a LogLocation,
|
||||
|
@ -549,7 +566,6 @@ impl<'a> LogRecord<'a> {
|
|||
}
|
||||
|
||||
/// Metadata about a log message.
|
||||
#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
|
||||
pub struct LogMetadata<'a> {
|
||||
level: LogLevel,
|
||||
target: &'a str,
|
||||
|
@ -601,7 +617,7 @@ impl Log for NopLogger {
|
|||
/// The fields of this struct are public so that they may be initialized by the
|
||||
/// `log!` macro. They are subject to change at any time and should never be
|
||||
/// accessed directly.
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct LogLocation {
|
||||
#[doc(hidden)]
|
||||
pub __module_path: &'static str,
|
||||
|
@ -636,7 +652,6 @@ impl LogLocation {
|
|||
/// higher than the maximum log level filter will be ignored. A logger should
|
||||
/// make sure to keep the maximum log level filter in sync with its current
|
||||
/// configuration.
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub struct MaxLogLevelFilter(());
|
||||
|
||||
impl fmt::Debug for MaxLogLevelFilter {
|
||||
|
@ -653,7 +668,7 @@ impl MaxLogLevelFilter {
|
|||
|
||||
/// Sets the maximum log level.
|
||||
pub fn set(&self, level: LogLevelFilter) {
|
||||
MAX_LOG_LEVEL_FILTER.store(level as usize, Ordering::SeqCst)
|
||||
log::set_max_level(level.to_new())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -664,7 +679,7 @@ impl MaxLogLevelFilter {
|
|||
/// log level is set by the `MaxLogLevel` token passed to loggers.
|
||||
#[inline(always)]
|
||||
pub fn max_log_level() -> LogLevelFilter {
|
||||
unsafe { mem::transmute(MAX_LOG_LEVEL_FILTER.load(Ordering::Relaxed)) }
|
||||
LogLevelFilter::from_new(log::max_level())
|
||||
}
|
||||
|
||||
/// Sets the global logger.
|
||||
|
@ -712,14 +727,15 @@ pub fn set_logger<M>(make_logger: M) -> Result<(), SetLoggerError>
|
|||
/// addition, `shutdown_logger` *must not* be called after this function.
|
||||
pub unsafe fn set_logger_raw<M>(make_logger: M) -> Result<(), SetLoggerError>
|
||||
where M: FnOnce(MaxLogLevelFilter) -> *const Log {
|
||||
if STATE.compare_and_swap(UNINITIALIZED, INITIALIZING,
|
||||
Ordering::SeqCst) != UNINITIALIZED {
|
||||
return Err(SetLoggerError(()));
|
||||
static ADAPTOR: LoggerAdaptor = LoggerAdaptor;
|
||||
match log::set_logger(&ADAPTOR) {
|
||||
Ok(()) => {
|
||||
LOGGER = make_logger(MaxLogLevelFilter(()));
|
||||
STATE.store(INITIALIZED, Ordering::SeqCst);
|
||||
Ok(())
|
||||
}
|
||||
Err(_) => Err(SetLoggerError(())),
|
||||
}
|
||||
|
||||
LOGGER = make_logger(MaxLogLevelFilter(()));
|
||||
STATE.store(INITIALIZED, Ordering::SeqCst);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Shuts down the global logger.
|
||||
|
@ -752,9 +768,6 @@ pub fn shutdown_logger() -> Result<Box<Log>, ShutdownLoggerError> {
|
|||
/// success. At that point it is guaranteed that no other threads are
|
||||
/// concurrently accessing the logger object.
|
||||
pub fn shutdown_logger_raw() -> Result<*const Log, ShutdownLoggerError> {
|
||||
// Set the global log level to stop other thread from logging
|
||||
MAX_LOG_LEVEL_FILTER.store(0, Ordering::SeqCst);
|
||||
|
||||
// Set to INITIALIZING to prevent re-initialization after
|
||||
if STATE.compare_and_swap(INITIALIZED, INITIALIZING,
|
||||
Ordering::SeqCst) != INITIALIZED {
|
||||
|
@ -873,15 +886,66 @@ fn logger() -> Option<LoggerGuard> {
|
|||
}
|
||||
}
|
||||
|
||||
struct LoggerAdaptor;
|
||||
|
||||
impl log::Log for LoggerAdaptor {
|
||||
fn log(&self, record: &log::Record) {
|
||||
if let Some(logger) = logger() {
|
||||
let record = LogRecord {
|
||||
metadata: LogMetadata {
|
||||
level: LogLevel::from_new(record.level()),
|
||||
target: record.target(),
|
||||
},
|
||||
// file and module path aren't static in 0.4 so we can't forward them.
|
||||
location: &LogLocation {
|
||||
__file: "<unknown>",
|
||||
__line: record.line().unwrap_or(0),
|
||||
__module_path: "<unknown>",
|
||||
},
|
||||
args: *record.args(),
|
||||
};
|
||||
logger.log(&record);
|
||||
}
|
||||
}
|
||||
|
||||
fn enabled(&self, metadata: &log::Metadata) -> bool {
|
||||
match logger() {
|
||||
Some(logger) => {
|
||||
let metadata = LogMetadata {
|
||||
level: LogLevel::from_new(metadata.level()),
|
||||
target: metadata.target(),
|
||||
};
|
||||
logger.enabled(&metadata)
|
||||
}
|
||||
None => false
|
||||
}
|
||||
}
|
||||
|
||||
fn flush(&self) {}
|
||||
}
|
||||
|
||||
// WARNING
|
||||
// This is not considered part of the crate's public API. It is subject to
|
||||
// change at any time.
|
||||
#[doc(hidden)]
|
||||
pub fn __enabled(level: LogLevel, target: &str) -> bool {
|
||||
if let Some(logger) = logger() {
|
||||
logger.enabled(&LogMetadata { level: level, target: target })
|
||||
} else {
|
||||
false
|
||||
match logger() {
|
||||
Some(logger) => {
|
||||
let metadata = LogMetadata {
|
||||
level: level,
|
||||
target: target,
|
||||
};
|
||||
logger.enabled(&metadata)
|
||||
}
|
||||
None => {
|
||||
log::Log::enabled(
|
||||
log::logger(),
|
||||
&log::Metadata::builder()
|
||||
.level(level.to_new())
|
||||
.target(target)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -891,16 +955,31 @@ pub fn __enabled(level: LogLevel, target: &str) -> bool {
|
|||
#[doc(hidden)]
|
||||
pub fn __log(level: LogLevel, target: &str, loc: &LogLocation,
|
||||
args: fmt::Arguments) {
|
||||
if let Some(logger) = logger() {
|
||||
let record = LogRecord {
|
||||
metadata: LogMetadata {
|
||||
level: level,
|
||||
target: target,
|
||||
},
|
||||
location: loc,
|
||||
args: args
|
||||
};
|
||||
logger.log(&record)
|
||||
match logger() {
|
||||
Some(logger) => {
|
||||
let record = LogRecord {
|
||||
metadata: LogMetadata {
|
||||
level: level,
|
||||
target: target,
|
||||
},
|
||||
location: loc,
|
||||
args: args,
|
||||
};
|
||||
logger.log(&record);
|
||||
}
|
||||
None => {
|
||||
log::Log::log(
|
||||
log::logger(),
|
||||
&log::Record::builder()
|
||||
.level(level.to_new())
|
||||
.target(target)
|
||||
.file(Some(loc.__file))
|
||||
.line(Some(loc.__line))
|
||||
.module_path(Some(loc.__module_path))
|
||||
.args(args)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -910,35 +989,7 @@ pub fn __log(level: LogLevel, target: &str, loc: &LogLocation,
|
|||
#[inline(always)]
|
||||
#[doc(hidden)]
|
||||
pub fn __static_max_level() -> LogLevelFilter {
|
||||
if !cfg!(debug_assertions) {
|
||||
// This is a release build. Check `release_max_level_*` first.
|
||||
if cfg!(feature = "release_max_level_off") {
|
||||
return LogLevelFilter::Off
|
||||
} else if cfg!(feature = "release_max_level_error") {
|
||||
return LogLevelFilter::Error
|
||||
} else if cfg!(feature = "release_max_level_warn") {
|
||||
return LogLevelFilter::Warn
|
||||
} else if cfg!(feature = "release_max_level_info") {
|
||||
return LogLevelFilter::Info
|
||||
} else if cfg!(feature = "release_max_level_debug") {
|
||||
return LogLevelFilter::Debug
|
||||
} else if cfg!(feature = "release_max_level_trace") {
|
||||
return LogLevelFilter::Trace
|
||||
}
|
||||
}
|
||||
if cfg!(feature = "max_level_off") {
|
||||
LogLevelFilter::Off
|
||||
} else if cfg!(feature = "max_level_error") {
|
||||
LogLevelFilter::Error
|
||||
} else if cfg!(feature = "max_level_warn") {
|
||||
LogLevelFilter::Warn
|
||||
} else if cfg!(feature = "max_level_info") {
|
||||
LogLevelFilter::Info
|
||||
} else if cfg!(feature = "max_level_debug") {
|
||||
LogLevelFilter::Debug
|
||||
} else {
|
||||
LogLevelFilter::Trace
|
||||
}
|
||||
LogLevelFilter::from_new(log::STATIC_MAX_LEVEL)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
|
@ -14,23 +14,6 @@
|
|||
///
|
||||
/// The `max_level_*` features can be used to statically disable logging at
|
||||
/// various levels.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[macro_use]
|
||||
/// # extern crate log;
|
||||
/// use log::LogLevel;
|
||||
///
|
||||
/// # fn main() {
|
||||
/// let data = (42, "Forty-two");
|
||||
/// let private_data = "private";
|
||||
///
|
||||
/// log!(LogLevel::Error, "Received errors: {}, {}", data.0, data.1);
|
||||
/// log!(target: "app_events", LogLevel::Warn, "App warning: {}, {}, {}",
|
||||
/// data.0, data.1, private_data);
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! log {
|
||||
(target: $target:expr, $lvl:expr, $($arg:tt)+) => ({
|
||||
|
@ -50,19 +33,6 @@ macro_rules! log {
|
|||
/// Logs a message at the error level.
|
||||
///
|
||||
/// Logging at this level is disabled if the `max_level_off` feature is present.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[macro_use]
|
||||
/// # extern crate log;
|
||||
/// # fn main() {
|
||||
/// let (err_info, port) = ("No connection", 22);
|
||||
///
|
||||
/// error!("Error: {} on port {}", err_info, port);
|
||||
/// error!(target: "app_events", "App Error: {}, Port: {}", err_info, 22);
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! error {
|
||||
(target: $target:expr, $($arg:tt)*) => (
|
||||
|
@ -81,19 +51,6 @@ macro_rules! error {
|
|||
/// When building in release mode (i.e., without the `debug_assertions` option),
|
||||
/// logging at this level is also disabled if any of the following features are
|
||||
/// present: `release_max_level_off` or `max_level_error`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[macro_use]
|
||||
/// # extern crate log;
|
||||
/// # fn main() {
|
||||
/// let warn_description = "Invalid Input";
|
||||
///
|
||||
/// warn!("Warning! {}!", warn_description);
|
||||
/// warn!(target: "input_events", "App received warning: {}", warn_description);
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! warn {
|
||||
(target: $target:expr, $($arg:tt)*) => (
|
||||
|
@ -113,21 +70,6 @@ macro_rules! warn {
|
|||
/// logging at this level is also disabled if any of the following features are
|
||||
/// present: `release_max_level_off`, `release_max_level_error`, or
|
||||
/// `release_max_level_warn`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[macro_use]
|
||||
/// # extern crate log;
|
||||
/// # fn main() {
|
||||
/// # struct Connection { port: u32, speed: f32 }
|
||||
/// let conn_info = Connection { port: 40, speed: 3.20 };
|
||||
///
|
||||
/// info!("Connected to port {} at {} Mb/s", conn_info.port, conn_info.speed);
|
||||
/// info!(target: "connection_events", "Successfull connection, port: {}, speed: {}",
|
||||
/// conn_info.port, conn_info.speed);
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! info {
|
||||
(target: $target:expr, $($arg:tt)*) => (
|
||||
|
@ -148,20 +90,6 @@ macro_rules! info {
|
|||
/// logging at this level is also disabled if any of the following features are
|
||||
/// present: `release_max_level_off`, `release_max_level_error`,
|
||||
/// `release_max_level_warn`, or `release_max_level_info`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[macro_use]
|
||||
/// # extern crate log;
|
||||
/// # fn main() {
|
||||
/// # struct Position { x: f32, y: f32 }
|
||||
/// let pos = Position { x: 3.234, y: -1.223 };
|
||||
///
|
||||
/// debug!("New position: x: {}, y: {}", pos.x, pos.y);
|
||||
/// debug!(target: "app_events", "New position: x: {}, y: {}", pos.x, pos.y);
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! debug {
|
||||
(target: $target:expr, $($arg:tt)*) => (
|
||||
|
@ -183,22 +111,6 @@ macro_rules! debug {
|
|||
/// present: `release_max_level_off`, `release_max_level_error`,
|
||||
/// `release_max_level_warn`, `release_max_level_info`, or
|
||||
/// `release_max_level_debug`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[macro_use]
|
||||
/// # extern crate log;
|
||||
/// # fn main() {
|
||||
/// # struct Position { x: f32, y: f32 }
|
||||
/// let pos = Position { x: 3.234, y: -1.223 };
|
||||
///
|
||||
/// trace!("Position is: x: {}, y: {}", pos.x, pos.y);
|
||||
/// trace!(target: "app_events", "x is {} and y is {}",
|
||||
/// if pos.x >= 0.0 { "positive" } else { "negative" },
|
||||
/// if pos.y >= 0.0 { "positive" } else { "negative" });
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! trace {
|
||||
(target: $target:expr, $($arg:tt)*) => (
|
Загрузка…
Ссылка в новой задаче