--- a/Cargo.lock
+++ b/Cargo.lock
@@ -54,17 +54,17 @@ version = "0.2.1"
dependencies = [
"bincode 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"cubeb 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.13 (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)",
"serde_derive 1.0.27 (git+https://github.com/gankro/serde?branch=deserialize_from_enums4)",
"tokio-core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-uds 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -74,33 +74,33 @@ name = "audioipc-client"
version = "0.3.0"
dependencies = [
"audioipc 0.2.1",
"cubeb-backend 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-cpupool 0.1.5 (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)",
]
[[package]]
name = "audioipc-server"
version = "0.2.2"
dependencies = [
"audioipc 0.2.1",
"bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"cubeb 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.13 (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)",
]
[[package]]
name = "base64"
version = "0.6.0"
@@ -554,17 +554,17 @@ dependencies = [
"simd 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
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)",
]
[[package]]
name = "env_logger"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
@@ -709,17 +709,17 @@ dependencies = [
name = "geckoservo"
version = "0.0.1"
dependencies = [
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)",
"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)",
"selectors 0.19.0",
"servo_arc 0.1.1",
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
"style_traits 0.0.1",
@@ -750,17 +750,17 @@ dependencies = [
"audioipc-client 0.3.0",
"audioipc-server 0.2.2",
"cose-c 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"cubeb-pulse 0.1.1",
"cubeb-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"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",
"nsstring 0.1.0",
"prefs_parser 0.0.1",
"rust_url_capi 0.0.1",
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
"u2fhid 0.1.0",
@@ -769,17 +769,17 @@ dependencies = [
]
[[package]]
name = "gl_generator"
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)",
]
[[package]]
name = "gleam"
version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
@@ -815,17 +815,17 @@ dependencies = [
[[package]]
name = "hyper"
version = "0.10.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
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)",
"traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -872,17 +872,17 @@ name = "js"
version = "0.1.4"
dependencies = [
"bindgen 0.33.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"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)",
]
[[package]]
name = "kernel32-sys"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -956,18 +956,21 @@ dependencies = [
"gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[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"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1025,17 +1028,17 @@ name = "memoffset"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
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]]
name = "miniz_oxide"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"adler32 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1057,17 +1060,17 @@ dependencies = [
name = "mio"
version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"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)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "mio-uds"
@@ -1537,17 +1540,17 @@ source = "registry+https://github.com/ru
[[package]]
name = "selectors"
version = "0.19.0"
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)",
"precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_arc 0.1.1",
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1654,17 +1657,17 @@ dependencies = [
"euclid 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fallible 0.0.1",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"hashglobe 0.1.0",
"itertools 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
"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)",
"nsstring 0.1.0",
"num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ordered-float 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1718,17 +1721,17 @@ version = "0.0.1"
dependencies = [
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)",
"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)",
"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",
"size_of_test 0.0.1",
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
"style_traits 0.0.1",
]
@@ -1844,43 +1847,43 @@ dependencies = [
[[package]]
name = "tokio-core"
version = "0.1.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.13 (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)",
"tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "tokio-io"
version = "0.1.3"
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.13 (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]]
name = "tokio-uds"
version = "0.1.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.13 (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)",
"tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "toml"
@@ -1902,17 +1905,17 @@ name = "u2fhid"
version = "0.1.0"
dependencies = [
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"boxfnonce 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation-sys 0.3.1 (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)",
"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)",
]
[[package]]
name = "uluru"
version = "0.2.0"
@@ -2308,17 +2311,17 @@ dependencies = [
"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
"checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d"
"checksum lazycell 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce12306c4739d86ee97c23139f3a34ddf0387bbf181bc7929d287025a8c3ef6b"
"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2"
"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"
"checksum memmap 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "46f3c7359028b31999287dae4e5047ddfe90a23b7dca2282ce759b491080c99b"
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
"checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0"
"checksum miniz_oxide 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aaa2d3ad070f428fffbd7d3ca2ea20bb0d8cffe9024405c44e1840bc1418b398"
"checksum miniz_oxide_c_api 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "92d98fdbd6145645828069b37ea92ca3de225e000d80702da25c20d3584b38a5"
deleted file mode 100644
--- a/third_party/rust/log-0.3.8/.cargo-checksum.json
+++ /dev/null
@@ -1,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"}
\ No newline at end of file
deleted file mode 100644
--- a/third_party/rust/log-0.3.8/.travis.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-language: rust
-sudo: false
-rust:
- - stable
- - beta
- - nightly
-before_script:
- - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
-script:
- - cargo build --verbose
- - ([ $TRAVIS_RUST_VERSION != nightly ] || cargo build --verbose --no-default-features)
- - ([ $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 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
- - cargo run --verbose --manifest-path tests/max_level_features/Cargo.toml --release
- - ([ $TRAVIS_RUST_VERSION != nightly ] || cargo doc --no-deps --features nightly)
- - CARGO_TARGET_DIR=target cargo doc --no-deps --manifest-path env/Cargo.toml
-after_success:
- - travis-cargo --only nightly doc-upload
-env:
- global:
- secure: "VPHgnszydMudYTY8cthHj/Dmxqp7OmTiu4Sa/705Udsx+tYblTv+8WdThkClo3C/asStVcxlaRWAp91UX32/k4SfkPz17XId3Wadyt03r73ANm6ZOWY+qty+3/LINm54kuTxYUDDTbD6NaFNPFQLIE0xCpJeiXUQTlaMk6z0W3M="
-
-notifications:
- email:
- on_success: never
deleted file mode 100644
--- a/third_party/rust/log-0.3.8/Cargo.toml
+++ /dev/null
@@ -1,49 +0,0 @@
-# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
-#
-# When uploading crates to the registry Cargo will automatically
-# "normalize" Cargo.toml files for maximal compatibility
-# with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g. crates.io) dependencies
-#
-# If you believe there's an error in this file please file an
-# issue against the rust-lang/cargo repository. If you're
-# editing this file be aware that the upstream Cargo.toml
-# will likely look very different (and much more reasonable)
-
-[package]
-name = "log"
-version = "0.3.8"
-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"
-readme = "README.md"
-categories = ["development-tools::debugging"]
-license = "MIT/Apache-2.0"
-repository = "https://github.com/rust-lang/log"
-
-[[test]]
-name = "filters"
-harness = false
-
-[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"
deleted file mode 100644
--- a/third_party/rust/log-0.3.8/README.md
+++ /dev/null
@@ -1,177 +0,0 @@
-log
-===
-
-A Rust library providing a lightweight logging *facade*.
-
-[![Build Status](https://travis-ci.org/rust-lang-nursery/log.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/log)
-[![Build status](https://ci.appveyor.com/api/projects/status/nopdjmmjt45xcrki?svg=true)](https://ci.appveyor.com/project/alexcrichton/log)
-
-* [`log` documentation](https://doc.rust-lang.org/log)
-* [`env_logger` documentation](https://doc.rust-lang.org/log/env_logger)
-
-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
-implementation that is most suitable for its use case.
-
-## Usage
-
-## In libraries
-
-Libraries should link only to the `log` crate, and use the provided macros to
-log whatever information will be useful to downstream consumers:
-
-```toml
-[dependencies]
-log = "0.3"
-```
-
-```rust
-#[macro_use]
-extern crate log;
-
-pub fn shave_the_yak(yak: &Yak) {
- trace!("Commencing yak shaving");
-
- loop {
- match find_a_razor() {
- Ok(razor) => {
- info!("Razor located: {}", razor);
- yak.shave(razor);
- break;
- }
- Err(err) => {
- warn!("Unable to locate a razor: {}, retrying", err);
- }
- }
- }
-}
-```
-
-## In executables
-
-Executables should choose a logger implementation and initialize it early in the
-runtime of the program. Logger implementations will typically include a
-function to do this. Any log messages generated before the logger is
-initialized will be ignored.
-
-The executable itself may use the `log` crate to log as well.
-
-The `env_logger` crate provides a logger implementation that mirrors the
-functionality of the old revision of the `log` crate.
-
-```toml
-[dependencies]
-log = "0.3"
-env_logger = "0.3"
-```
-
-```rust
-#[macro_use]
-extern crate log;
-extern crate env_logger;
-
-fn main() {
- env_logger::init().unwrap();
-
- info!("starting up");
-
- // ...
-}
-```
-
-## In tests
-
-Tests can use the `env_logger` crate to see log messages generated during that test:
-
-```toml
-[dependencies]
-log = "0.3"
-
-[dev-dependencies]
-env_logger = "0.3"
-```
-
-```rust
-#[macro_use]
-extern crate log;
-
-fn add_one(num: i32) -> i32 {
- info!("add_one called with {}", num);
- num + 1
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
- extern crate env_logger;
-
- #[test]
- fn it_adds_one() {
- let _ = env_logger::init();
- info!("can log from the test too");
- assert_eq!(3, add_one(2));
- }
-
- #[test]
- fn it_handles_negative_numbers() {
- let _ = env_logger::init();
- info!("logging from another test");
- assert_eq!(-7, add_one(-8));
- }
-}
-```
-
-Assuming the module under test is called `my_lib`, running the tests with the
-`RUST_LOG` filtering to info messages from this module looks like:
-
-```bash
-$ RUST_LOG=my_lib=info cargo test
- Running target/debug/my_lib-...
-
-running 2 tests
-INFO:my_lib::tests: logging from another test
-INFO:my_lib: add_one called with -8
-test tests::it_handles_negative_numbers ... ok
-INFO:my_lib::tests: can log from the test too
-INFO:my_lib: add_one called with 2
-test tests::it_adds_one ... ok
-
-test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured
-```
-
-Note that `env_logger::init()` needs to be called in each test in which you
-want to enable logging. Additionally, the default behavior of tests to
-run in parallel means that logging output may be interleaved with test output.
-Either run tests in a single thread by specifying `RUST_TEST_THREADS=1` or by
-running one test by specifying its name as an argument to the test binaries as
-directed by the `cargo test` help docs:
-
-```bash
-$ RUST_LOG=my_lib=info cargo test it_adds_one
- Running target/debug/my_lib-...
-
-running 1 test
-INFO:my_lib::tests: can log from the test too
-INFO:my_lib: add_one called with 2
-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();
-```
deleted file mode 100644
--- a/third_party/rust/log-0.3.8/src/lib.rs
+++ /dev/null
@@ -1,1040 +0,0 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! A lightweight logging facade.
-//!
-//! The `log` crate 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.
-//!
-//! If no logging implementation is selected, the facade falls back to a "noop"
-//! 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.
-//!
-//! # Use
-//!
-//! ## In libraries
-//!
-//! Libraries should link only to the `log` crate, and use the provided
-//! macros to log whatever information will be useful to downstream consumers.
-//!
-//! ### Examples
-//!
-//! ```rust
-//! # #![allow(unstable)]
-//! #[macro_use]
-//! extern crate log;
-//!
-//! # #[derive(Debug)] pub struct Yak(String);
-//! # impl Yak { fn shave(&self, _: u32) {} }
-//! # fn find_a_razor() -> Result<u32, u32> { Ok(1) }
-//! pub fn shave_the_yak(yak: &Yak) {
-//! info!(target: "yak_events", "Commencing yak shaving for {:?}", yak);
-//!
-//! loop {
-//! match find_a_razor() {
-//! Ok(razor) => {
-//! info!("Razor located: {}", razor);
-//! yak.shave(razor);
-//! break;
-//! }
-//! Err(err) => {
-//! warn!("Unable to locate a razor: {}, retrying", err);
-//! }
-//! }
-//! }
-//! }
-//! # fn main() {}
-//! ```
-//!
-//! ## In executables
-//!
-//! Executables should choose a logging framework and initialize it early in the
-//! runtime of the program. Logging frameworks will typically include a
-//! function to do this. Any log messages generated before the framework is
-//! initialized will be ignored.
-//!
-//! The executable itself may use the `log` crate to log as well.
-//!
-//! ### Warning
-//!
-//! The logging system may only be initialized once.
-//!
-//! ### Examples
-//!
-//! ```rust,ignore
-//! #[macro_use]
-//! extern crate log;
-//! extern crate env_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();
-//!
-//! 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:
-//!
-//! ```rust
-//! extern crate log;
-//!
-//! use log::{LogRecord, LogLevel, LogMetadata};
-//!
-//! struct SimpleLogger;
-//!
-//! impl log::Log for SimpleLogger {
-//! fn enabled(&self, metadata: &LogMetadata) -> bool {
-//! metadata.level() <= LogLevel::Info
-//! }
-//!
-//! fn log(&self, record: &LogRecord) {
-//! if self.enabled(record.metadata()) {
-//! println!("{} - {}", record.level(), record.args());
-//! }
-//! }
-//! }
-//!
-//! # 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:
-//!
-//! ```rust
-//! # extern crate log;
-//! # use log::{LogLevel, LogLevelFilter, SetLoggerError, LogMetadata};
-//! # struct SimpleLogger;
-//! # impl log::Log for SimpleLogger {
-//! # fn enabled(&self, _: &LogMetadata) -> bool { false }
-//! # fn log(&self, _: &log::LogRecord) {}
-//! # }
-//! # fn main() {}
-//! # #[cfg(feature = "use_std")]
-//! pub fn init() -> Result<(), SetLoggerError> {
-//! log::set_logger(|max_log_level| {
-//! max_log_level.set(LogLevelFilter::Info);
-//! Box::new(SimpleLogger)
-//! })
-//! }
-//! ```
-//!
-//! # Use with `no_std`
-//!
-//! 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
-//! shut down the global logger before exiting:
-//!
-//! ```rust
-//! # extern crate log;
-//! # use log::{LogLevel, LogLevelFilter, SetLoggerError, ShutdownLoggerError,
-//! # LogMetadata};
-//! # struct SimpleLogger;
-//! # impl log::Log for SimpleLogger {
-//! # fn enabled(&self, _: &LogMetadata) -> bool { false }
-//! # fn log(&self, _: &log::LogRecord) {}
-//! # }
-//! # impl SimpleLogger {
-//! # fn flush(&self) {}
-//! # }
-//! # fn main() {}
-//! pub fn init() -> Result<(), SetLoggerError> {
-//! unsafe {
-//! log::set_logger_raw(|max_log_level| {
-//! static LOGGER: SimpleLogger = SimpleLogger;
-//! max_log_level.set(LogLevelFilter::Info);
-//! &SimpleLogger
-//! })
-//! }
-//! }
-//! pub fn shutdown() -> Result<(), ShutdownLoggerError> {
-//! log::shutdown_logger_raw().map(|logger| {
-//! let logger = unsafe { &*(logger as *const SimpleLogger) };
-//! logger.flush();
-//! })
-//! }
-//! ```
-//!
-//! [`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)]
-
-// When compiled for the rustc compiler itself we want to make sure that this is
-// an unstable crate
-#![cfg_attr(rustbuild, feature(staged_api, rustc_private))]
-#![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))]
-
-#[cfg(not(feature = "use_std"))]
-extern crate core as std;
-
-use std::cmp;
-#[cfg(feature = "use_std")]
-use std::error;
-use std::fmt;
-use std::mem;
-use std::ops::Deref;
-use std::str::FromStr;
-use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
-#[macro_use]
-mod macros;
-
-// The setup here is a bit weird to make shutdown_logger_raw work.
-//
-// There are four different states that we care about: the logger's
-// uninitialized, the logger's initializing (set_logger's been called but
-// LOGGER hasn't actually been set yet), the logger's active, or the logger is
-// shut down after calling shutdown_logger_raw.
-//
-// The LOGGER static holds a pointer to the global logger. It is protected by
-// the STATE static which determines whether LOGGER has been initialized yet.
-//
-// The shutdown_logger_raw routine needs to make sure that no threads are
-// actively logging before it returns. The number of actively logging threads is
-// tracked in the REFCOUNT static. The routine first sets STATE back to
-// INITIALIZING. All logging calls past that point will immediately return
-// without accessing the logger. At that point, the at_exit routine just waits
-// for the refcount to reach 0 before deallocating the logger. Note that the
-// refcount does not necessarily monotonically decrease at this point, as new
-// log calls still increment and decrement it, but the interval in between is
-// small enough that the wait is really just for the active log calls to finish.
-
-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.
-///
-/// 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).
-#[repr(usize)]
-#[derive(Copy, Eq, Debug, Hash)]
-pub enum LogLevel {
- /// The "error" level.
- ///
- /// Designates very serious errors.
- Error = 1, // This way these line up with the discriminants for LogLevelFilter below
- /// The "warn" level.
- ///
- /// Designates hazardous situations.
- Warn,
- /// The "info" level.
- ///
- /// Designates useful information.
- Info,
- /// The "debug" level.
- ///
- /// Designates lower priority information.
- Debug,
- /// The "trace" level.
- ///
- /// Designates very low priority, often extremely verbose, information.
- Trace,
-}
-
-impl Clone for LogLevel {
- #[inline]
- fn clone(&self) -> LogLevel {
- *self
- }
-}
-
-impl PartialEq for LogLevel {
- #[inline]
- fn eq(&self, other: &LogLevel) -> bool {
- *self as usize == *other as usize
- }
-}
-
-impl PartialEq<LogLevelFilter> for LogLevel {
- #[inline]
- fn eq(&self, other: &LogLevelFilter) -> bool {
- *self as usize == *other as usize
- }
-}
-
-impl PartialOrd for LogLevel {
- #[inline]
- fn partial_cmp(&self, other: &LogLevel) -> Option<cmp::Ordering> {
- Some(self.cmp(other))
- }
-}
-
-impl PartialOrd<LogLevelFilter> for LogLevel {
- #[inline]
- fn partial_cmp(&self, other: &LogLevelFilter) -> Option<cmp::Ordering> {
- Some((*self as usize).cmp(&(*other as usize)))
- }
-}
-
-impl Ord for LogLevel {
- #[inline]
- fn cmp(&self, other: &LogLevel) -> cmp::Ordering {
- (*self as usize).cmp(&(*other as usize))
- }
-}
-
-fn ok_or<T, E>(t: Option<T>, e: E) -> Result<T, E> {
- match t {
- Some(t) => Ok(t),
- None => Err(e),
- }
-}
-
-// Reimplemented here because std::ascii is not available in libcore
-fn eq_ignore_ascii_case(a: &str, b: &str) -> bool {
- fn to_ascii_uppercase(c: u8) -> u8 {
- if c >= b'a' && c <= b'z' {
- c - b'a' + b'A'
- } else {
- c
- }
- }
-
- if a.len() == b.len() {
- a.bytes()
- .zip(b.bytes())
- .all(|(a, b)| to_ascii_uppercase(a) == to_ascii_uppercase(b))
- } else {
- false
- }
-}
-
-impl FromStr for LogLevel {
- type Err = ();
- fn from_str(level: &str) -> Result<LogLevel, ()> {
- ok_or(LOG_LEVEL_NAMES.iter()
- .position(|&name| eq_ignore_ascii_case(name, level))
- .into_iter()
- .filter(|&idx| idx != 0)
- .map(|idx| LogLevel::from_usize(idx).unwrap())
- .next(), ())
- }
-}
-
-impl fmt::Display for LogLevel {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- fmt.pad(LOG_LEVEL_NAMES[*self as usize])
- }
-}
-
-impl LogLevel {
- fn from_usize(u: usize) -> Option<LogLevel> {
- match u {
- 1 => Some(LogLevel::Error),
- 2 => Some(LogLevel::Warn),
- 3 => Some(LogLevel::Info),
- 4 => Some(LogLevel::Debug),
- 5 => Some(LogLevel::Trace),
- _ => None
- }
- }
-
- /// Returns the most verbose logging level.
- #[inline]
- pub fn max() -> LogLevel {
- LogLevel::Trace
- }
-
- /// Converts the `LogLevel` to the equivalent `LogLevelFilter`.
- #[inline]
- pub fn to_log_level_filter(&self) -> LogLevelFilter {
- LogLevelFilter::from_usize(*self as usize).unwrap()
- }
-}
-
-/// 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).
-#[repr(usize)]
-#[derive(Copy, Eq, Debug, Hash)]
-pub enum LogLevelFilter {
- /// A level lower than all log levels.
- Off,
- /// Corresponds to the `Error` log level.
- Error,
- /// Corresponds to the `Warn` log level.
- Warn,
- /// Corresponds to the `Info` log level.
- Info,
- /// Corresponds to the `Debug` log level.
- Debug,
- /// Corresponds to the `Trace` log level.
- Trace,
-}
-
-// Deriving generates terrible impls of these traits
-
-impl Clone for LogLevelFilter {
- #[inline]
- fn clone(&self) -> LogLevelFilter {
- *self
- }
-}
-
-impl PartialEq for LogLevelFilter {
- #[inline]
- fn eq(&self, other: &LogLevelFilter) -> bool {
- *self as usize == *other as usize
- }
-}
-
-impl PartialEq<LogLevel> for LogLevelFilter {
- #[inline]
- fn eq(&self, other: &LogLevel) -> bool {
- other.eq(self)
- }
-}
-
-impl PartialOrd for LogLevelFilter {
- #[inline]
- fn partial_cmp(&self, other: &LogLevelFilter) -> Option<cmp::Ordering> {
- Some(self.cmp(other))
- }
-}
-
-impl PartialOrd<LogLevel> for LogLevelFilter {
- #[inline]
- fn partial_cmp(&self, other: &LogLevel) -> Option<cmp::Ordering> {
- other.partial_cmp(self).map(|x| x.reverse())
- }
-}
-
-impl Ord for LogLevelFilter {
- #[inline]
- fn cmp(&self, other: &LogLevelFilter) -> cmp::Ordering {
- (*self as usize).cmp(&(*other as usize))
- }
-}
-
-impl FromStr for LogLevelFilter {
- type Err = ();
- fn from_str(level: &str) -> Result<LogLevelFilter, ()> {
- ok_or(LOG_LEVEL_NAMES.iter()
- .position(|&name| eq_ignore_ascii_case(name, level))
- .map(|p| LogLevelFilter::from_usize(p).unwrap()), ())
- }
-}
-
-impl fmt::Display for LogLevelFilter {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- write!(fmt, "{}", LOG_LEVEL_NAMES[*self as usize])
- }
-}
-
-impl LogLevelFilter {
- fn from_usize(u: usize) -> Option<LogLevelFilter> {
- match u {
- 0 => Some(LogLevelFilter::Off),
- 1 => Some(LogLevelFilter::Error),
- 2 => Some(LogLevelFilter::Warn),
- 3 => Some(LogLevelFilter::Info),
- 4 => Some(LogLevelFilter::Debug),
- 5 => Some(LogLevelFilter::Trace),
- _ => None
- }
- }
- /// Returns the most verbose logging level filter.
- #[inline]
- pub fn max() -> LogLevelFilter {
- LogLevelFilter::Trace
- }
-
- /// Converts `self` to the equivalent `LogLevel`.
- ///
- /// Returns `None` if `self` is `LogLevelFilter::Off`.
- #[inline]
- pub fn to_log_level(&self) -> Option<LogLevel> {
- LogLevel::from_usize(*self as usize)
- }
-}
-
-/// 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)]
-pub struct LogRecord<'a> {
- metadata: LogMetadata<'a>,
- location: &'a LogLocation,
- args: fmt::Arguments<'a>,
-}
-
-impl<'a> LogRecord<'a> {
- /// The message body.
- pub fn args(&self) -> &fmt::Arguments<'a> {
- &self.args
- }
-
- /// Metadata about the log directive.
- pub fn metadata(&self) -> &LogMetadata {
- &self.metadata
- }
-
- /// The location of the log directive.
- pub fn location(&self) -> &LogLocation {
- self.location
- }
-
- /// The verbosity level of the message.
- pub fn level(&self) -> LogLevel {
- self.metadata.level()
- }
-
- /// The name of the target of the directive.
- pub fn target(&self) -> &str {
- self.metadata.target()
- }
-}
-
-/// Metadata about a log message.
-#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
-pub struct LogMetadata<'a> {
- level: LogLevel,
- target: &'a str,
-}
-
-impl<'a> LogMetadata<'a> {
- /// The verbosity level of the message.
- pub fn level(&self) -> LogLevel {
- self.level
- }
-
- /// The name of the target of the directive.
- pub fn target(&self) -> &str {
- self.target
- }
-}
-
-/// A trait encapsulating the operations required of a logger
-pub trait Log: Sync+Send {
- /// Determines if a log message with the specified metadata would be
- /// logged.
- ///
- /// This is used by the `log_enabled!` macro to allow callers to avoid
- /// expensive computation of log message arguments if the message would be
- /// discarded anyway.
- fn enabled(&self, metadata: &LogMetadata) -> bool;
-
- /// Logs the `LogRecord`.
- ///
- /// Note that `enabled` is *not* necessarily called before this method.
- /// Implementations of `log` should perform all necessary filtering
- /// internally.
- fn log(&self, record: &LogRecord);
-}
-
-// Just used as a dummy initial value for LOGGER
-struct NopLogger;
-
-impl Log for NopLogger {
- fn enabled(&self, _: &LogMetadata) -> bool { false }
-
- fn log(&self, _: &LogRecord) {}
-}
-
-/// The location of a log message.
-///
-/// # Warning
-///
-/// 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)]
-pub struct LogLocation {
- #[doc(hidden)]
- pub __module_path: &'static str,
- #[doc(hidden)]
- pub __file: &'static str,
- #[doc(hidden)]
- pub __line: u32,
-}
-
-impl LogLocation {
- /// The module path of the message.
- pub fn module_path(&self) -> &str {
- self.__module_path
- }
-
- /// The source file containing the message.
- pub fn file(&self) -> &str {
- self.__file
- }
-
- /// The line containing the message.
- pub fn line(&self) -> u32 {
- self.__line
- }
-}
-
-/// A token providing read and write access to the global maximum log level
-/// filter.
-///
-/// The maximum log level is used as an optimization to avoid evaluating log
-/// messages that will be ignored by the logger. Any message with a level
-/// 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 {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- write!(fmt, "MaxLogLevelFilter")
- }
-}
-
-impl MaxLogLevelFilter {
- /// Gets the current maximum log level filter.
- pub fn get(&self) -> LogLevelFilter {
- max_log_level()
- }
-
- /// Sets the maximum log level.
- pub fn set(&self, level: LogLevelFilter) {
- MAX_LOG_LEVEL_FILTER.store(level as usize, Ordering::SeqCst)
- }
-}
-
-/// Returns the current maximum log level.
-///
-/// The `log!`, `error!`, `warn!`, `info!`, `debug!`, and `trace!` macros check
-/// this value and discard any message logged at a higher level. The maximum
-/// 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)) }
-}
-
-/// Sets the global logger.
-///
-/// The `make_logger` closure is passed a `MaxLogLevel` object, which the
-/// logger should use to keep the global maximum log level in sync with the
-/// highest log level that the logger will not ignore.
-///
-/// This function may only be called once in the lifetime of a program. Any log
-/// events that occur before the call to `set_logger` completes will be
-/// ignored.
-///
-/// This function does not typically need to be called manually. Logger
-/// implementations should provide an initialization method that calls
-/// `set_logger` internally.
-///
-/// Requires the `use_std` feature (enabled by default).
-#[cfg(feature = "use_std")]
-pub fn set_logger<M>(make_logger: M) -> Result<(), SetLoggerError>
- where M: FnOnce(MaxLogLevelFilter) -> Box<Log> {
- unsafe { set_logger_raw(|max_level| mem::transmute(make_logger(max_level))) }
-}
-
-/// Sets the global logger from a raw pointer.
-///
-/// This function is similar to `set_logger` except that it is usable in
-/// `no_std` code.
-///
-/// The `make_logger` closure is passed a `MaxLogLevel` object, which the
-/// logger should use to keep the global maximum log level in sync with the
-/// highest log level that the logger will not ignore.
-///
-/// This function may only be called once in the lifetime of a program. Any log
-/// events that occur before the call to `set_logger_raw` completes will be
-/// ignored.
-///
-/// This function does not typically need to be called manually. Logger
-/// implementations should provide an initialization method that calls
-/// `set_logger_raw` internally.
-///
-/// # Safety
-///
-/// The pointer returned by `make_logger` must remain valid for the entire
-/// duration of the program or until `shutdown_logger_raw` is called. In
-/// 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(()));
- }
-
- LOGGER = make_logger(MaxLogLevelFilter(()));
- STATE.store(INITIALIZED, Ordering::SeqCst);
- Ok(())
-}
-
-/// Shuts down the global logger.
-///
-/// This function may only be called once in the lifetime of a program, and may
-/// not be called before `set_logger`. Once the global logger has been shut
-/// down, it can no longer be re-initialized by `set_logger`. Any log events
-/// that occur after the call to `shutdown_logger` completes will be ignored.
-///
-/// The logger that was originally created by the call to to `set_logger` is
-/// returned on success. At that point it is guaranteed that no other threads
-/// are concurrently accessing the logger object.
-#[cfg(feature = "use_std")]
-pub fn shutdown_logger() -> Result<Box<Log>, ShutdownLoggerError> {
- shutdown_logger_raw().map(|l| unsafe { mem::transmute(l) })
-}
-
-/// Shuts down the global logger.
-///
-/// This function is similar to `shutdown_logger` except that it is usable in
-/// `no_std` code.
-///
-/// This function may only be called once in the lifetime of a program, and may
-/// not be called before `set_logger_raw`. Once the global logger has been shut
-/// down, it can no longer be re-initialized by `set_logger_raw`. Any log
-/// events that occur after the call to `shutdown_logger_raw` completes will be
-/// ignored.
-///
-/// The pointer that was originally passed to `set_logger_raw` is returned on
-/// 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 {
- return Err(ShutdownLoggerError(()));
- }
-
- while REFCOUNT.load(Ordering::SeqCst) != 0 {
- // FIXME add a sleep here when it doesn't involve timers
- }
-
- unsafe {
- let logger = LOGGER;
- LOGGER = &NopLogger;
- Ok(logger)
- }
-}
-
-/// The type returned by `set_logger` if `set_logger` has already been called.
-#[allow(missing_copy_implementations)]
-#[derive(Debug)]
-pub struct SetLoggerError(());
-
-impl fmt::Display for SetLoggerError {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- write!(fmt, "attempted to set a logger after the logging system \
- was already initialized")
- }
-}
-
-// The Error trait is not available in libcore
-#[cfg(feature = "use_std")]
-impl error::Error for SetLoggerError {
- fn description(&self) -> &str { "set_logger() called multiple times" }
-}
-
-/// The type returned by `shutdown_logger_raw` if `shutdown_logger_raw` has
-/// already been called or if `set_logger_raw` has not been called yet.
-#[allow(missing_copy_implementations)]
-#[derive(Debug)]
-pub struct ShutdownLoggerError(());
-
-impl fmt::Display for ShutdownLoggerError {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- write!(fmt, "attempted to shut down the logger without an active logger")
- }
-}
-
-// The Error trait is not available in libcore
-#[cfg(feature = "use_std")]
-impl error::Error for ShutdownLoggerError {
- fn description(&self) -> &str { "shutdown_logger() called without an active logger" }
-}
-
-/// Deprecated
-///
-/// Use https://crates.io/crates/log-panics instead.
-#[cfg(all(feature = "nightly", feature = "use_std"))]
-pub fn log_panics() {
- std::panic::set_hook(Box::new(panic::log));
-}
-
-// inner module so that the reporting module is log::panic instead of log
-#[cfg(all(feature = "nightly", feature = "use_std"))]
-mod panic {
- use std::panic::PanicInfo;
- use std::thread;
-
- pub fn log(info: &PanicInfo) {
- let thread = thread::current();
- let thread = thread.name().unwrap_or("<unnamed>");
-
- let msg = match info.payload().downcast_ref::<&'static str>() {
- Some(s) => *s,
- None => match info.payload().downcast_ref::<String>() {
- Some(s) => &s[..],
- None => "Box<Any>",
- }
- };
-
- match info.location() {
- Some(location) => {
- error!("thread '{}' panicked at '{}': {}:{}",
- thread,
- msg,
- location.file(),
- location.line())
- }
- None => error!("thread '{}' panicked at '{}'", thread, msg),
- }
- }
-}
-
-struct LoggerGuard(&'static Log);
-
-impl Drop for LoggerGuard {
- fn drop(&mut self) {
- REFCOUNT.fetch_sub(1, Ordering::SeqCst);
- }
-}
-
-impl Deref for LoggerGuard {
- type Target = Log;
-
- fn deref(&self) -> &(Log + 'static) {
- self.0
- }
-}
-
-fn logger() -> Option<LoggerGuard> {
- REFCOUNT.fetch_add(1, Ordering::SeqCst);
- if STATE.load(Ordering::SeqCst) != INITIALIZED {
- REFCOUNT.fetch_sub(1, Ordering::SeqCst);
- None
- } else {
- Some(LoggerGuard(unsafe { &*LOGGER }))
- }
-}
-
-// 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
- }
-}
-
-// WARNING
-// This is not considered part of the crate's public API. It is subject to
-// change at any time.
-#[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)
- }
-}
-
-// WARNING
-// This is not considered part of the crate's public API. It is subject to
-// change at any time.
-#[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
- }
-}
-
-#[cfg(test)]
-mod tests {
- extern crate std;
- use tests::std::string::ToString;
- use super::{LogLevel, LogLevelFilter};
-
- #[test]
- fn test_loglevelfilter_from_str() {
- let tests = [
- ("off", Ok(LogLevelFilter::Off)),
- ("error", Ok(LogLevelFilter::Error)),
- ("warn", Ok(LogLevelFilter::Warn)),
- ("info", Ok(LogLevelFilter::Info)),
- ("debug", Ok(LogLevelFilter::Debug)),
- ("trace", Ok(LogLevelFilter::Trace)),
- ("OFF", Ok(LogLevelFilter::Off)),
- ("ERROR", Ok(LogLevelFilter::Error)),
- ("WARN", Ok(LogLevelFilter::Warn)),
- ("INFO", Ok(LogLevelFilter::Info)),
- ("DEBUG", Ok(LogLevelFilter::Debug)),
- ("TRACE", Ok(LogLevelFilter::Trace)),
- ("asdf", Err(())),
- ];
- for &(s, ref expected) in &tests {
- assert_eq!(expected, &s.parse());
- }
- }
-
- #[test]
- fn test_loglevel_from_str() {
- let tests = [
- ("OFF", Err(())),
- ("error", Ok(LogLevel::Error)),
- ("warn", Ok(LogLevel::Warn)),
- ("info", Ok(LogLevel::Info)),
- ("debug", Ok(LogLevel::Debug)),
- ("trace", Ok(LogLevel::Trace)),
- ("ERROR", Ok(LogLevel::Error)),
- ("WARN", Ok(LogLevel::Warn)),
- ("INFO", Ok(LogLevel::Info)),
- ("DEBUG", Ok(LogLevel::Debug)),
- ("TRACE", Ok(LogLevel::Trace)),
- ("asdf", Err(())),
- ];
- for &(s, ref expected) in &tests {
- assert_eq!(expected, &s.parse());
- }
- }
-
- #[test]
- fn test_loglevel_show() {
- assert_eq!("INFO", LogLevel::Info.to_string());
- assert_eq!("ERROR", LogLevel::Error.to_string());
- }
-
- #[test]
- fn test_loglevelfilter_show() {
- assert_eq!("OFF", LogLevelFilter::Off.to_string());
- assert_eq!("ERROR", LogLevelFilter::Error.to_string());
- }
-
- #[test]
- fn test_cross_cmp() {
- assert!(LogLevel::Debug > LogLevelFilter::Error);
- assert!(LogLevelFilter::Warn < LogLevel::Trace);
- assert!(LogLevelFilter::Off < LogLevel::Error);
- }
-
- #[test]
- fn test_cross_eq() {
- assert!(LogLevel::Error == LogLevelFilter::Error);
- assert!(LogLevelFilter::Off != LogLevel::Error);
- assert!(LogLevel::Trace == LogLevelFilter::Trace);
- }
-
- #[test]
- fn test_to_log_level() {
- assert_eq!(Some(LogLevel::Error), LogLevelFilter::Error.to_log_level());
- assert_eq!(None, LogLevelFilter::Off.to_log_level());
- assert_eq!(Some(LogLevel::Debug), LogLevelFilter::Debug.to_log_level());
- }
-
- #[test]
- fn test_to_log_level_filter() {
- assert_eq!(LogLevelFilter::Error, LogLevel::Error.to_log_level_filter());
- assert_eq!(LogLevelFilter::Trace, LogLevel::Trace.to_log_level_filter());
- }
-
- #[test]
- #[cfg(feature = "use_std")]
- fn test_error_trait() {
- use std::error::Error;
- use super::SetLoggerError;
- let e = SetLoggerError(());
- assert_eq!(e.description(), "set_logger() called multiple times");
- }
-}
deleted file mode 100644
--- a/third_party/rust/log-0.3.8/src/macros.rs
+++ /dev/null
@@ -1,243 +0,0 @@
-// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-/// The standard logging macro.
-///
-/// This macro will generically log with the specified `LogLevel` and `format!`
-/// based argument list.
-///
-/// 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)+) => ({
- static _LOC: $crate::LogLocation = $crate::LogLocation {
- __line: line!(),
- __file: file!(),
- __module_path: module_path!(),
- };
- let lvl = $lvl;
- if lvl <= $crate::__static_max_level() && lvl <= $crate::max_log_level() {
- $crate::__log(lvl, $target, &_LOC, format_args!($($arg)+))
- }
- });
- ($lvl:expr, $($arg:tt)+) => (log!(target: module_path!(), $lvl, $($arg)+))
-}
-
-/// 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)*) => (
- log!(target: $target, $crate::LogLevel::Error, $($arg)*);
- );
- ($($arg:tt)*) => (
- log!($crate::LogLevel::Error, $($arg)*);
- )
-}
-
-/// Logs a message at the warn level.
-///
-/// Logging at this level is disabled if any of the following features are
-/// present: `max_level_off` or `max_level_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)*) => (
- log!(target: $target, $crate::LogLevel::Warn, $($arg)*);
- );
- ($($arg:tt)*) => (
- log!($crate::LogLevel::Warn, $($arg)*);
- )
-}
-
-/// Logs a message at the info level.
-///
-/// Logging at this level is disabled if any of the following features are
-/// present: `max_level_off`, `max_level_error`, or `max_level_warn`.
-///
-/// 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`, `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)*) => (
- log!(target: $target, $crate::LogLevel::Info, $($arg)*);
- );
- ($($arg:tt)*) => (
- log!($crate::LogLevel::Info, $($arg)*);
- )
-}
-
-/// Logs a message at the debug level.
-///
-/// Logging at this level is disabled if any of the following features are
-/// present: `max_level_off`, `max_level_error`, `max_level_warn`, or
-/// `max_level_info`.
-///
-/// 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`, `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)*) => (
- log!(target: $target, $crate::LogLevel::Debug, $($arg)*);
- );
- ($($arg:tt)*) => (
- log!($crate::LogLevel::Debug, $($arg)*);
- )
-}
-
-/// Logs a message at the trace level.
-///
-/// Logging at this level is disabled if any of the following features are
-/// present: `max_level_off`, `max_level_error`, `max_level_warn`,
-/// `max_level_info`, or `max_level_debug`.
-///
-/// 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`, `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)*) => (
- log!(target: $target, $crate::LogLevel::Trace, $($arg)*);
- );
- ($($arg:tt)*) => (
- log!($crate::LogLevel::Trace, $($arg)*);
- )
-}
-
-/// Determines if a message logged at the specified level in that module will
-/// be logged.
-///
-/// This can be used to avoid expensive computation of log message arguments if
-/// the message would be ignored anyway.
-///
-/// # Examples
-///
-/// ```rust
-/// # #[macro_use]
-/// # extern crate log;
-/// use log::LogLevel::Debug;
-///
-/// # fn foo() {
-/// if log_enabled!(Debug) {
-/// let data = expensive_call();
-/// debug!("expensive debug data: {} {}", data.x, data.y);
-/// }
-/// # }
-/// # struct Data { x: u32, y: u32 }
-/// # fn expensive_call() -> Data { Data { x: 0, y: 0 } }
-/// # fn main() {}
-/// ```
-#[macro_export]
-macro_rules! log_enabled {
- (target: $target:expr, $lvl:expr) => ({
- let lvl = $lvl;
- lvl <= $crate::__static_max_level() && lvl <= $crate::max_log_level() &&
- $crate::__enabled(lvl, $target)
- });
- ($lvl:expr) => (log_enabled!(target: module_path!(), $lvl))
-}
deleted file mode 100644
--- a/third_party/rust/log-0.3.8/tests/filters.rs
+++ /dev/null
@@ -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;
-}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/log-0.3.9/.cargo-checksum.json
@@ -0,0 +1,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"}
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/third_party/rust/log-0.3.9/.travis.yml
@@ -0,0 +1,30 @@
+language: rust
+sudo: false
+rust:
+ - stable
+ - beta
+ - nightly
+before_script:
+ - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
+script:
+ - cargo build --verbose
+ - ([ $TRAVIS_RUST_VERSION != nightly ] || cargo build --verbose --no-default-features)
+ - ([ $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
+ - cargo run --verbose --manifest-path tests/max_level_features/Cargo.toml --release
+ - ([ $TRAVIS_RUST_VERSION != nightly ] || cargo doc --no-deps --features nightly)
+ - CARGO_TARGET_DIR=target cargo doc --no-deps --manifest-path env/Cargo.toml
+after_success:
+ - travis-cargo --only nightly doc-upload
+env:
+ global:
+ secure: "VPHgnszydMudYTY8cthHj/Dmxqp7OmTiu4Sa/705Udsx+tYblTv+8WdThkClo3C/asStVcxlaRWAp91UX32/k4SfkPz17XId3Wadyt03r73ANm6ZOWY+qty+3/LINm54kuTxYUDDTbD6NaFNPFQLIE0xCpJeiXUQTlaMk6z0W3M="
+
+notifications:
+ email:
+ on_success: never
new file mode 100644
--- /dev/null
+++ b/third_party/rust/log-0.3.9/Cargo.toml
@@ -0,0 +1,45 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g. crates.io) dependencies
+#
+# If you believe there's an error in this file please file an
+# issue against the rust-lang/cargo repository. If you're
+# editing this file be aware that the upstream Cargo.toml
+# will likely look very different (and much more reasonable)
+
+[package]
+name = "log"
+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://doc.rust-lang.org/log"
+readme = "README.md"
+categories = ["development-tools::debugging"]
+license = "MIT/Apache-2.0"
+repository = "https://github.com/rust-lang/log"
+
+[lib]
+doctest = false
+[dependencies.log]
+version = "0.4"
+
+[features]
+default = ["use_std"]
+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"]
rename from third_party/rust/log-0.3.8/LICENSE-APACHE
rename to third_party/rust/log-0.3.9/LICENSE-APACHE
rename from third_party/rust/log-0.3.8/LICENSE-MIT
rename to third_party/rust/log-0.3.9/LICENSE-MIT
new file mode 100644
--- /dev/null
+++ b/third_party/rust/log-0.3.9/README.md
@@ -0,0 +1,160 @@
+log
+===
+
+A Rust library providing a lightweight logging *facade*.
+
+[![Build Status](https://travis-ci.org/rust-lang-nursery/log.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/log)
+[![Build status](https://ci.appveyor.com/api/projects/status/nopdjmmjt45xcrki?svg=true)](https://ci.appveyor.com/project/alexcrichton/log)
+
+* [`log` documentation](https://doc.rust-lang.org/log)
+* [`env_logger` documentation](https://doc.rust-lang.org/log/env_logger)
+
+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
+implementation that is most suitable for its use case.
+
+## Usage
+
+## In libraries
+
+Libraries should link only to the `log` crate, and use the provided macros to
+log whatever information will be useful to downstream consumers:
+
+```toml
+[dependencies]
+log = "0.3"
+```
+
+```rust
+#[macro_use]
+extern crate log;
+
+pub fn shave_the_yak(yak: &Yak) {
+ trace!("Commencing yak shaving");
+
+ loop {
+ match find_a_razor() {
+ Ok(razor) => {
+ info!("Razor located: {}", razor);
+ yak.shave(razor);
+ break;
+ }
+ Err(err) => {
+ warn!("Unable to locate a razor: {}, retrying", err);
+ }
+ }
+ }
+}
+```
+
+## In executables
+
+Executables should choose a logger implementation and initialize it early in the
+runtime of the program. Logger implementations will typically include a
+function to do this. Any log messages generated before the logger is
+initialized will be ignored.
+
+The executable itself may use the `log` crate to log as well.
+
+The `env_logger` crate provides a logger implementation that mirrors the
+functionality of the old revision of the `log` crate.
+
+```toml
+[dependencies]
+log = "0.3"
+env_logger = "0.3"
+```
+
+```rust
+#[macro_use]
+extern crate log;
+extern crate env_logger;
+
+fn main() {
+ env_logger::init().unwrap();
+
+ info!("starting up");
+
+ // ...
+}
+```
+
+## In tests
+
+Tests can use the `env_logger` crate to see log messages generated during that test:
+
+```toml
+[dependencies]
+log = "0.3"
+
+[dev-dependencies]
+env_logger = "0.3"
+```
+
+```rust
+#[macro_use]
+extern crate log;
+
+fn add_one(num: i32) -> i32 {
+ info!("add_one called with {}", num);
+ num + 1
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ extern crate env_logger;
+
+ #[test]
+ fn it_adds_one() {
+ let _ = env_logger::init();
+ info!("can log from the test too");
+ assert_eq!(3, add_one(2));
+ }
+
+ #[test]
+ fn it_handles_negative_numbers() {
+ let _ = env_logger::init();
+ info!("logging from another test");
+ assert_eq!(-7, add_one(-8));
+ }
+}
+```
+
+Assuming the module under test is called `my_lib`, running the tests with the
+`RUST_LOG` filtering to info messages from this module looks like:
+
+```bash
+$ RUST_LOG=my_lib=info cargo test
+ Running target/debug/my_lib-...
+
+running 2 tests
+INFO:my_lib::tests: logging from another test
+INFO:my_lib: add_one called with -8
+test tests::it_handles_negative_numbers ... ok
+INFO:my_lib::tests: can log from the test too
+INFO:my_lib: add_one called with 2
+test tests::it_adds_one ... ok
+
+test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured
+```
+
+Note that `env_logger::init()` needs to be called in each test in which you
+want to enable logging. Additionally, the default behavior of tests to
+run in parallel means that logging output may be interleaved with test output.
+Either run tests in a single thread by specifying `RUST_TEST_THREADS=1` or by
+running one test by specifying its name as an argument to the test binaries as
+directed by the `cargo test` help docs:
+
+```bash
+$ RUST_LOG=my_lib=info cargo test it_adds_one
+ Running target/debug/my_lib-...
+
+running 1 test
+INFO:my_lib::tests: can log from the test too
+INFO:my_lib: add_one called with 2
+test tests::it_adds_one ... ok
+
+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
+```
rename from third_party/rust/log-0.3.8/appveyor.yml
rename to third_party/rust/log-0.3.9/appveyor.yml
new file mode 100644
--- /dev/null
+++ b/third_party/rust/log-0.3.9/src/lib.rs
@@ -0,0 +1,1091 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! A lightweight logging facade.
+//!
+//! 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.
+//!
+//! If no logging implementation is selected, the facade falls back to a "noop"
+//! 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.
+//!
+//! # Use
+//!
+//! ## In libraries
+//!
+//! Libraries should link only to the `log` crate, and use the provided
+//! macros to log whatever information will be useful to downstream consumers.
+//!
+//! ### Examples
+//!
+//! ```rust
+//! # #![allow(unstable)]
+//! #[macro_use]
+//! extern crate log;
+//!
+//! # #[derive(Debug)] pub struct Yak(String);
+//! # impl Yak { fn shave(&self, _: u32) {} }
+//! # fn find_a_razor() -> Result<u32, u32> { Ok(1) }
+//! pub fn shave_the_yak(yak: &Yak) {
+//! info!(target: "yak_events", "Commencing yak shaving for {:?}", yak);
+//!
+//! loop {
+//! match find_a_razor() {
+//! Ok(razor) => {
+//! info!("Razor located: {}", razor);
+//! yak.shave(razor);
+//! break;
+//! }
+//! Err(err) => {
+//! warn!("Unable to locate a razor: {}, retrying", err);
+//! }
+//! }
+//! }
+//! }
+//! # fn main() {}
+//! ```
+//!
+//! ## In executables
+//!
+//! Executables should choose a logging framework and initialize it early in the
+//! runtime of the program. Logging frameworks will typically include a
+//! function to do this. Any log messages generated before the framework is
+//! initialized will be ignored.
+//!
+//! The executable itself may use the `log` crate to log as well.
+//!
+//! ### Warning
+//!
+//! The logging system may only be initialized once.
+//!
+//! ### Examples
+//!
+//! ```rust,ignore
+//! #[macro_use]
+//! extern crate log;
+//! extern crate my_logger;
+//!
+//! fn main() {
+//! my_logger::init();
+//!
+//! info!("starting up");
+//!
+//! // ...
+//! }
+//! ```
+//!
+//! # Logger implementations
+//!
+//! 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;
+//!
+//! use log::{LogRecord, LogLevel, LogMetadata};
+//!
+//! struct SimpleLogger;
+//!
+//! impl log::Log for SimpleLogger {
+//! fn enabled(&self, metadata: &LogMetadata) -> bool {
+//! metadata.level() <= LogLevel::Info
+//! }
+//!
+//! fn log(&self, record: &LogRecord) {
+//! if self.enabled(record.metadata()) {
+//! println!("{} - {}", record.level(), record.args());
+//! }
+//! }
+//! }
+//!
+//! # fn main() {}
+//! ```
+//!
+//! 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;
+//! # use log::{LogLevel, LogLevelFilter, SetLoggerError, LogMetadata};
+//! # struct SimpleLogger;
+//! # impl log::Log for SimpleLogger {
+//! # fn enabled(&self, _: &LogMetadata) -> bool { false }
+//! # fn log(&self, _: &log::LogRecord) {}
+//! # }
+//! # fn main() {}
+//! # #[cfg(feature = "use_std")]
+//! pub fn init() -> Result<(), SetLoggerError> {
+//! log::set_logger(|max_log_level| {
+//! max_log_level.set(LogLevelFilter::Info);
+//! Box::new(SimpleLogger)
+//! })
+//! }
+//! ```
+//!
+//! # Use with `no_std`
+//!
+//! 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
+//! shut down the global logger before exiting:
+//!
+//! ```rust
+//! # extern crate log;
+//! # use log::{LogLevel, LogLevelFilter, SetLoggerError, ShutdownLoggerError,
+//! # LogMetadata};
+//! # struct SimpleLogger;
+//! # impl log::Log for SimpleLogger {
+//! # fn enabled(&self, _: &LogMetadata) -> bool { false }
+//! # fn log(&self, _: &log::LogRecord) {}
+//! # }
+//! # impl SimpleLogger {
+//! # fn flush(&self) {}
+//! # }
+//! # fn main() {}
+//! pub fn init() -> Result<(), SetLoggerError> {
+//! unsafe {
+//! log::set_logger_raw(|max_log_level| {
+//! static LOGGER: SimpleLogger = SimpleLogger;
+//! max_log_level.set(LogLevelFilter::Info);
+//! &SimpleLogger
+//! })
+//! }
+//! }
+//! pub fn shutdown() -> Result<(), ShutdownLoggerError> {
+//! log::shutdown_logger_raw().map(|logger| {
+//! let logger = unsafe { &*(logger as *const SimpleLogger) };
+//! logger.flush();
+//! })
+//! }
+//! ```
+
+#![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)]
+#![cfg_attr(feature = "nightly", feature(panic_handler))]
+
+#![cfg_attr(not(feature = "use_std"), no_std)]
+
+// When compiled for the rustc compiler itself we want to make sure that this is
+// an unstable crate
+#![cfg_attr(rustbuild, feature(staged_api, rustc_private))]
+#![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))]
+
+#[cfg(not(feature = "use_std"))]
+extern crate core as std;
+extern crate log;
+
+use std::cmp;
+#[cfg(feature = "use_std")]
+use std::error;
+use std::fmt;
+use std::mem;
+use std::ops::Deref;
+use std::str::FromStr;
+use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
+#[macro_use]
+mod macros;
+
+// The setup here is a bit weird to make shutdown_logger_raw work.
+//
+// There are four different states that we care about: the logger's
+// uninitialized, the logger's initializing (set_logger's been called but
+// LOGGER hasn't actually been set yet), the logger's active, or the logger is
+// shut down after calling shutdown_logger_raw.
+//
+// The LOGGER static holds a pointer to the global logger. It is protected by
+// the STATE static which determines whether LOGGER has been initialized yet.
+//
+// The shutdown_logger_raw routine needs to make sure that no threads are
+// actively logging before it returns. The number of actively logging threads is
+// tracked in the REFCOUNT static. The routine first sets STATE back to
+// INITIALIZING. All logging calls past that point will immediately return
+// without accessing the logger. At that point, the at_exit routine just waits
+// for the refcount to reach 0 before deallocating the logger. Note that the
+// refcount does not necessarily monotonically decrease at this point, as new
+// log calls still increment and decrement it, but the interval in between is
+// small enough that the wait is really just for the active log calls to finish.
+
+static mut LOGGER: *const Log = &NopLogger;
+static STATE: AtomicUsize = ATOMIC_USIZE_INIT;
+static REFCOUNT: AtomicUsize = ATOMIC_USIZE_INIT;
+
+const INITIALIZING: usize = 1;
+const INITIALIZED: usize = 2;
+
+static LOG_LEVEL_NAMES: [&'static str; 6] = ["OFF", "ERROR", "WARN", "INFO",
+ "DEBUG", "TRACE"];
+
+/// An enum representing the available verbosity levels of the logging framework
+///
+/// A `LogLevel` may be compared directly to a `LogLevelFilter`.
+#[repr(usize)]
+#[derive(Copy, Eq, Debug)]
+pub enum LogLevel {
+ /// The "error" level.
+ ///
+ /// Designates very serious errors.
+ Error = 1, // This way these line up with the discriminants for LogLevelFilter below
+ /// The "warn" level.
+ ///
+ /// Designates hazardous situations.
+ Warn,
+ /// The "info" level.
+ ///
+ /// Designates useful information.
+ Info,
+ /// The "debug" level.
+ ///
+ /// Designates lower priority information.
+ Debug,
+ /// The "trace" level.
+ ///
+ /// Designates very low priority, often extremely verbose, information.
+ Trace,
+}
+
+impl Clone for LogLevel {
+ #[inline]
+ fn clone(&self) -> LogLevel {
+ *self
+ }
+}
+
+impl PartialEq for LogLevel {
+ #[inline]
+ fn eq(&self, other: &LogLevel) -> bool {
+ *self as usize == *other as usize
+ }
+}
+
+impl PartialEq<LogLevelFilter> for LogLevel {
+ #[inline]
+ fn eq(&self, other: &LogLevelFilter) -> bool {
+ *self as usize == *other as usize
+ }
+}
+
+impl PartialOrd for LogLevel {
+ #[inline]
+ fn partial_cmp(&self, other: &LogLevel) -> Option<cmp::Ordering> {
+ Some(self.cmp(other))
+ }
+}
+
+impl PartialOrd<LogLevelFilter> for LogLevel {
+ #[inline]
+ fn partial_cmp(&self, other: &LogLevelFilter) -> Option<cmp::Ordering> {
+ Some((*self as usize).cmp(&(*other as usize)))
+ }
+}
+
+impl Ord for LogLevel {
+ #[inline]
+ fn cmp(&self, other: &LogLevel) -> cmp::Ordering {
+ (*self as usize).cmp(&(*other as usize))
+ }
+}
+
+fn ok_or<T, E>(t: Option<T>, e: E) -> Result<T, E> {
+ match t {
+ Some(t) => Ok(t),
+ None => Err(e),
+ }
+}
+
+// Reimplemented here because std::ascii is not available in libcore
+fn eq_ignore_ascii_case(a: &str, b: &str) -> bool {
+ fn to_ascii_uppercase(c: u8) -> u8 {
+ if c >= b'a' && c <= b'z' {
+ c - b'a' + b'A'
+ } else {
+ c
+ }
+ }
+
+ if a.len() == b.len() {
+ a.bytes()
+ .zip(b.bytes())
+ .all(|(a, b)| to_ascii_uppercase(a) == to_ascii_uppercase(b))
+ } else {
+ false
+ }
+}
+
+impl FromStr for LogLevel {
+ type Err = ();
+ fn from_str(level: &str) -> Result<LogLevel, ()> {
+ ok_or(LOG_LEVEL_NAMES.iter()
+ .position(|&name| eq_ignore_ascii_case(name, level))
+ .into_iter()
+ .filter(|&idx| idx != 0)
+ .map(|idx| LogLevel::from_usize(idx).unwrap())
+ .next(), ())
+ }
+}
+
+impl fmt::Display for LogLevel {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fmt.pad(LOG_LEVEL_NAMES[*self as usize])
+ }
+}
+
+impl LogLevel {
+ fn from_usize(u: usize) -> Option<LogLevel> {
+ match u {
+ 1 => Some(LogLevel::Error),
+ 2 => Some(LogLevel::Warn),
+ 3 => Some(LogLevel::Info),
+ 4 => Some(LogLevel::Debug),
+ 5 => Some(LogLevel::Trace),
+ _ => None
+ }
+ }
+
+ 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 {
+ LogLevel::Trace
+ }
+
+ /// Converts the `LogLevel` to the equivalent `LogLevelFilter`.
+ #[inline]
+ pub fn to_log_level_filter(&self) -> LogLevelFilter {
+ LogLevelFilter::from_usize(*self as usize).unwrap()
+ }
+}
+
+/// An enum representing the available verbosity level filters of the logging
+/// framework.
+///
+/// A `LogLevelFilter` may be compared directly to a `LogLevel`.
+#[repr(usize)]
+#[derive(Copy, Eq, Debug)]
+pub enum LogLevelFilter {
+ /// A level lower than all log levels.
+ Off,
+ /// Corresponds to the `Error` log level.
+ Error,
+ /// Corresponds to the `Warn` log level.
+ Warn,
+ /// Corresponds to the `Info` log level.
+ Info,
+ /// Corresponds to the `Debug` log level.
+ Debug,
+ /// Corresponds to the `Trace` log level.
+ Trace,
+}
+
+// Deriving generates terrible impls of these traits
+
+impl Clone for LogLevelFilter {
+ #[inline]
+ fn clone(&self) -> LogLevelFilter {
+ *self
+ }
+}
+
+impl PartialEq for LogLevelFilter {
+ #[inline]
+ fn eq(&self, other: &LogLevelFilter) -> bool {
+ *self as usize == *other as usize
+ }
+}
+
+impl PartialEq<LogLevel> for LogLevelFilter {
+ #[inline]
+ fn eq(&self, other: &LogLevel) -> bool {
+ other.eq(self)
+ }
+}
+
+impl PartialOrd for LogLevelFilter {
+ #[inline]
+ fn partial_cmp(&self, other: &LogLevelFilter) -> Option<cmp::Ordering> {
+ Some(self.cmp(other))
+ }
+}
+
+impl PartialOrd<LogLevel> for LogLevelFilter {
+ #[inline]
+ fn partial_cmp(&self, other: &LogLevel) -> Option<cmp::Ordering> {
+ other.partial_cmp(self).map(|x| x.reverse())
+ }
+}
+
+impl Ord for LogLevelFilter {
+ #[inline]
+ fn cmp(&self, other: &LogLevelFilter) -> cmp::Ordering {
+ (*self as usize).cmp(&(*other as usize))
+ }
+}
+
+impl FromStr for LogLevelFilter {
+ type Err = ();
+ fn from_str(level: &str) -> Result<LogLevelFilter, ()> {
+ ok_or(LOG_LEVEL_NAMES.iter()
+ .position(|&name| eq_ignore_ascii_case(name, level))
+ .map(|p| LogLevelFilter::from_usize(p).unwrap()), ())
+ }
+}
+
+impl fmt::Display for LogLevelFilter {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ write!(fmt, "{}", LOG_LEVEL_NAMES[*self as usize])
+ }
+}
+
+impl LogLevelFilter {
+ fn from_usize(u: usize) -> Option<LogLevelFilter> {
+ match u {
+ 0 => Some(LogLevelFilter::Off),
+ 1 => Some(LogLevelFilter::Error),
+ 2 => Some(LogLevelFilter::Warn),
+ 3 => Some(LogLevelFilter::Info),
+ 4 => Some(LogLevelFilter::Debug),
+ 5 => Some(LogLevelFilter::Trace),
+ _ => 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 {
+ LogLevelFilter::Trace
+ }
+
+ /// Converts `self` to the equivalent `LogLevel`.
+ ///
+ /// Returns `None` if `self` is `LogLevelFilter::Off`.
+ #[inline]
+ pub fn to_log_level(&self) -> Option<LogLevel> {
+ LogLevel::from_usize(*self as usize)
+ }
+}
+
+/// The "payload" of a log message.
+pub struct LogRecord<'a> {
+ metadata: LogMetadata<'a>,
+ location: &'a LogLocation,
+ args: fmt::Arguments<'a>,
+}
+
+impl<'a> LogRecord<'a> {
+ /// The message body.
+ pub fn args(&self) -> &fmt::Arguments<'a> {
+ &self.args
+ }
+
+ /// Metadata about the log directive.
+ pub fn metadata(&self) -> &LogMetadata {
+ &self.metadata
+ }
+
+ /// The location of the log directive.
+ pub fn location(&self) -> &LogLocation {
+ self.location
+ }
+
+ /// The verbosity level of the message.
+ pub fn level(&self) -> LogLevel {
+ self.metadata.level()
+ }
+
+ /// The name of the target of the directive.
+ pub fn target(&self) -> &str {
+ self.metadata.target()
+ }
+}
+
+/// Metadata about a log message.
+pub struct LogMetadata<'a> {
+ level: LogLevel,
+ target: &'a str,
+}
+
+impl<'a> LogMetadata<'a> {
+ /// The verbosity level of the message.
+ pub fn level(&self) -> LogLevel {
+ self.level
+ }
+
+ /// The name of the target of the directive.
+ pub fn target(&self) -> &str {
+ self.target
+ }
+}
+
+/// A trait encapsulating the operations required of a logger
+pub trait Log: Sync+Send {
+ /// Determines if a log message with the specified metadata would be
+ /// logged.
+ ///
+ /// This is used by the `log_enabled!` macro to allow callers to avoid
+ /// expensive computation of log message arguments if the message would be
+ /// discarded anyway.
+ fn enabled(&self, metadata: &LogMetadata) -> bool;
+
+ /// Logs the `LogRecord`.
+ ///
+ /// Note that `enabled` is *not* necessarily called before this method.
+ /// Implementations of `log` should perform all necessary filtering
+ /// internally.
+ fn log(&self, record: &LogRecord);
+}
+
+// Just used as a dummy initial value for LOGGER
+struct NopLogger;
+
+impl Log for NopLogger {
+ fn enabled(&self, _: &LogMetadata) -> bool { false }
+
+ fn log(&self, _: &LogRecord) {}
+}
+
+/// The location of a log message.
+///
+/// # Warning
+///
+/// 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)]
+pub struct LogLocation {
+ #[doc(hidden)]
+ pub __module_path: &'static str,
+ #[doc(hidden)]
+ pub __file: &'static str,
+ #[doc(hidden)]
+ pub __line: u32,
+}
+
+impl LogLocation {
+ /// The module path of the message.
+ pub fn module_path(&self) -> &str {
+ self.__module_path
+ }
+
+ /// The source file containing the message.
+ pub fn file(&self) -> &str {
+ self.__file
+ }
+
+ /// The line containing the message.
+ pub fn line(&self) -> u32 {
+ self.__line
+ }
+}
+
+/// A token providing read and write access to the global maximum log level
+/// filter.
+///
+/// The maximum log level is used as an optimization to avoid evaluating log
+/// messages that will be ignored by the logger. Any message with a level
+/// 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.
+pub struct MaxLogLevelFilter(());
+
+impl fmt::Debug for MaxLogLevelFilter {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ write!(fmt, "MaxLogLevelFilter")
+ }
+}
+
+impl MaxLogLevelFilter {
+ /// Gets the current maximum log level filter.
+ pub fn get(&self) -> LogLevelFilter {
+ max_log_level()
+ }
+
+ /// Sets the maximum log level.
+ pub fn set(&self, level: LogLevelFilter) {
+ log::set_max_level(level.to_new())
+ }
+}
+
+/// Returns the current maximum log level.
+///
+/// The `log!`, `error!`, `warn!`, `info!`, `debug!`, and `trace!` macros check
+/// this value and discard any message logged at a higher level. The maximum
+/// log level is set by the `MaxLogLevel` token passed to loggers.
+#[inline(always)]
+pub fn max_log_level() -> LogLevelFilter {
+ LogLevelFilter::from_new(log::max_level())
+}
+
+/// Sets the global logger.
+///
+/// The `make_logger` closure is passed a `MaxLogLevel` object, which the
+/// logger should use to keep the global maximum log level in sync with the
+/// highest log level that the logger will not ignore.
+///
+/// This function may only be called once in the lifetime of a program. Any log
+/// events that occur before the call to `set_logger` completes will be
+/// ignored.
+///
+/// This function does not typically need to be called manually. Logger
+/// implementations should provide an initialization method that calls
+/// `set_logger` internally.
+///
+/// Requires the `use_std` feature (enabled by default).
+#[cfg(feature = "use_std")]
+pub fn set_logger<M>(make_logger: M) -> Result<(), SetLoggerError>
+ where M: FnOnce(MaxLogLevelFilter) -> Box<Log> {
+ unsafe { set_logger_raw(|max_level| mem::transmute(make_logger(max_level))) }
+}
+
+/// Sets the global logger from a raw pointer.
+///
+/// This function is similar to `set_logger` except that it is usable in
+/// `no_std` code.
+///
+/// The `make_logger` closure is passed a `MaxLogLevel` object, which the
+/// logger should use to keep the global maximum log level in sync with the
+/// highest log level that the logger will not ignore.
+///
+/// This function may only be called once in the lifetime of a program. Any log
+/// events that occur before the call to `set_logger_raw` completes will be
+/// ignored.
+///
+/// This function does not typically need to be called manually. Logger
+/// implementations should provide an initialization method that calls
+/// `set_logger_raw` internally.
+///
+/// # Safety
+///
+/// The pointer returned by `make_logger` must remain valid for the entire
+/// duration of the program or until `shutdown_logger_raw` is called. In
+/// 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 {
+ static ADAPTOR: LoggerAdaptor = LoggerAdaptor;
+ match log::set_logger(&ADAPTOR) {
+ Ok(()) => {
+ LOGGER = make_logger(MaxLogLevelFilter(()));
+ STATE.store(INITIALIZED, Ordering::SeqCst);
+ Ok(())
+ }
+ Err(_) => Err(SetLoggerError(())),
+ }
+}
+
+/// Shuts down the global logger.
+///
+/// This function may only be called once in the lifetime of a program, and may
+/// not be called before `set_logger`. Once the global logger has been shut
+/// down, it can no longer be re-initialized by `set_logger`. Any log events
+/// that occur after the call to `shutdown_logger` completes will be ignored.
+///
+/// The logger that was originally created by the call to to `set_logger` is
+/// returned on success. At that point it is guaranteed that no other threads
+/// are concurrently accessing the logger object.
+#[cfg(feature = "use_std")]
+pub fn shutdown_logger() -> Result<Box<Log>, ShutdownLoggerError> {
+ shutdown_logger_raw().map(|l| unsafe { mem::transmute(l) })
+}
+
+/// Shuts down the global logger.
+///
+/// This function is similar to `shutdown_logger` except that it is usable in
+/// `no_std` code.
+///
+/// This function may only be called once in the lifetime of a program, and may
+/// not be called before `set_logger_raw`. Once the global logger has been shut
+/// down, it can no longer be re-initialized by `set_logger_raw`. Any log
+/// events that occur after the call to `shutdown_logger_raw` completes will be
+/// ignored.
+///
+/// The pointer that was originally passed to `set_logger_raw` is returned on
+/// 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 to INITIALIZING to prevent re-initialization after
+ if STATE.compare_and_swap(INITIALIZED, INITIALIZING,
+ Ordering::SeqCst) != INITIALIZED {
+ return Err(ShutdownLoggerError(()));
+ }
+
+ while REFCOUNT.load(Ordering::SeqCst) != 0 {
+ // FIXME add a sleep here when it doesn't involve timers
+ }
+
+ unsafe {
+ let logger = LOGGER;
+ LOGGER = &NopLogger;
+ Ok(logger)
+ }
+}
+
+/// The type returned by `set_logger` if `set_logger` has already been called.
+#[allow(missing_copy_implementations)]
+#[derive(Debug)]
+pub struct SetLoggerError(());
+
+impl fmt::Display for SetLoggerError {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ write!(fmt, "attempted to set a logger after the logging system \
+ was already initialized")
+ }
+}
+
+// The Error trait is not available in libcore
+#[cfg(feature = "use_std")]
+impl error::Error for SetLoggerError {
+ fn description(&self) -> &str { "set_logger() called multiple times" }
+}
+
+/// The type returned by `shutdown_logger_raw` if `shutdown_logger_raw` has
+/// already been called or if `set_logger_raw` has not been called yet.
+#[allow(missing_copy_implementations)]
+#[derive(Debug)]
+pub struct ShutdownLoggerError(());
+
+impl fmt::Display for ShutdownLoggerError {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ write!(fmt, "attempted to shut down the logger without an active logger")
+ }
+}
+
+// The Error trait is not available in libcore
+#[cfg(feature = "use_std")]
+impl error::Error for ShutdownLoggerError {
+ fn description(&self) -> &str { "shutdown_logger() called without an active logger" }
+}
+
+/// Deprecated
+///
+/// Use https://crates.io/crates/log-panics instead.
+#[cfg(all(feature = "nightly", feature = "use_std"))]
+pub fn log_panics() {
+ std::panic::set_hook(Box::new(panic::log));
+}
+
+// inner module so that the reporting module is log::panic instead of log
+#[cfg(all(feature = "nightly", feature = "use_std"))]
+mod panic {
+ use std::panic::PanicInfo;
+ use std::thread;
+
+ pub fn log(info: &PanicInfo) {
+ let thread = thread::current();
+ let thread = thread.name().unwrap_or("<unnamed>");
+
+ let msg = match info.payload().downcast_ref::<&'static str>() {
+ Some(s) => *s,
+ None => match info.payload().downcast_ref::<String>() {
+ Some(s) => &s[..],
+ None => "Box<Any>",
+ }
+ };
+
+ match info.location() {
+ Some(location) => {
+ error!("thread '{}' panicked at '{}': {}:{}",
+ thread,
+ msg,
+ location.file(),
+ location.line())
+ }
+ None => error!("thread '{}' panicked at '{}'", thread, msg),
+ }
+ }
+}
+
+struct LoggerGuard(&'static Log);
+
+impl Drop for LoggerGuard {
+ fn drop(&mut self) {
+ REFCOUNT.fetch_sub(1, Ordering::SeqCst);
+ }
+}
+
+impl Deref for LoggerGuard {
+ type Target = Log;
+
+ fn deref(&self) -> &(Log + 'static) {
+ self.0
+ }
+}
+
+fn logger() -> Option<LoggerGuard> {
+ REFCOUNT.fetch_add(1, Ordering::SeqCst);
+ if STATE.load(Ordering::SeqCst) != INITIALIZED {
+ REFCOUNT.fetch_sub(1, Ordering::SeqCst);
+ None
+ } else {
+ Some(LoggerGuard(unsafe { &*LOGGER }))
+ }
+}
+
+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 {
+ 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()
+ )
+ }
+ }
+}
+
+// WARNING
+// This is not considered part of the crate's public API. It is subject to
+// change at any time.
+#[doc(hidden)]
+pub fn __log(level: LogLevel, target: &str, loc: &LogLocation,
+ args: fmt::Arguments) {
+ 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()
+ )
+ }
+ }
+}
+
+// WARNING
+// This is not considered part of the crate's public API. It is subject to
+// change at any time.
+#[inline(always)]
+#[doc(hidden)]
+pub fn __static_max_level() -> LogLevelFilter {
+ LogLevelFilter::from_new(log::STATIC_MAX_LEVEL)
+}
+
+#[cfg(test)]
+mod tests {
+ extern crate std;
+ use tests::std::string::ToString;
+ use super::{LogLevel, LogLevelFilter};
+
+ #[test]
+ fn test_loglevelfilter_from_str() {
+ let tests = [
+ ("off", Ok(LogLevelFilter::Off)),
+ ("error", Ok(LogLevelFilter::Error)),
+ ("warn", Ok(LogLevelFilter::Warn)),
+ ("info", Ok(LogLevelFilter::Info)),
+ ("debug", Ok(LogLevelFilter::Debug)),
+ ("trace", Ok(LogLevelFilter::Trace)),
+ ("OFF", Ok(LogLevelFilter::Off)),
+ ("ERROR", Ok(LogLevelFilter::Error)),
+ ("WARN", Ok(LogLevelFilter::Warn)),
+ ("INFO", Ok(LogLevelFilter::Info)),
+ ("DEBUG", Ok(LogLevelFilter::Debug)),
+ ("TRACE", Ok(LogLevelFilter::Trace)),
+ ("asdf", Err(())),
+ ];
+ for &(s, ref expected) in &tests {
+ assert_eq!(expected, &s.parse());
+ }
+ }
+
+ #[test]
+ fn test_loglevel_from_str() {
+ let tests = [
+ ("OFF", Err(())),
+ ("error", Ok(LogLevel::Error)),
+ ("warn", Ok(LogLevel::Warn)),
+ ("info", Ok(LogLevel::Info)),
+ ("debug", Ok(LogLevel::Debug)),
+ ("trace", Ok(LogLevel::Trace)),
+ ("ERROR", Ok(LogLevel::Error)),
+ ("WARN", Ok(LogLevel::Warn)),
+ ("INFO", Ok(LogLevel::Info)),
+ ("DEBUG", Ok(LogLevel::Debug)),
+ ("TRACE", Ok(LogLevel::Trace)),
+ ("asdf", Err(())),
+ ];
+ for &(s, ref expected) in &tests {
+ assert_eq!(expected, &s.parse());
+ }
+ }
+
+ #[test]
+ fn test_loglevel_show() {
+ assert_eq!("INFO", LogLevel::Info.to_string());
+ assert_eq!("ERROR", LogLevel::Error.to_string());
+ }
+
+ #[test]
+ fn test_loglevelfilter_show() {
+ assert_eq!("OFF", LogLevelFilter::Off.to_string());
+ assert_eq!("ERROR", LogLevelFilter::Error.to_string());
+ }
+
+ #[test]
+ fn test_cross_cmp() {
+ assert!(LogLevel::Debug > LogLevelFilter::Error);
+ assert!(LogLevelFilter::Warn < LogLevel::Trace);
+ assert!(LogLevelFilter::Off < LogLevel::Error);
+ }
+
+ #[test]
+ fn test_cross_eq() {
+ assert!(LogLevel::Error == LogLevelFilter::Error);
+ assert!(LogLevelFilter::Off != LogLevel::Error);
+ assert!(LogLevel::Trace == LogLevelFilter::Trace);
+ }
+
+ #[test]
+ fn test_to_log_level() {
+ assert_eq!(Some(LogLevel::Error), LogLevelFilter::Error.to_log_level());
+ assert_eq!(None, LogLevelFilter::Off.to_log_level());
+ assert_eq!(Some(LogLevel::Debug), LogLevelFilter::Debug.to_log_level());
+ }
+
+ #[test]
+ fn test_to_log_level_filter() {
+ assert_eq!(LogLevelFilter::Error, LogLevel::Error.to_log_level_filter());
+ assert_eq!(LogLevelFilter::Trace, LogLevel::Trace.to_log_level_filter());
+ }
+
+ #[test]
+ #[cfg(feature = "use_std")]
+ fn test_error_trait() {
+ use std::error::Error;
+ use super::SetLoggerError;
+ let e = SetLoggerError(());
+ assert_eq!(e.description(), "set_logger() called multiple times");
+ }
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/log-0.3.9/src/macros.rs
@@ -0,0 +1,155 @@
+// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+/// The standard logging macro.
+///
+/// This macro will generically log with the specified `LogLevel` and `format!`
+/// based argument list.
+///
+/// The `max_level_*` features can be used to statically disable logging at
+/// various levels.
+#[macro_export]
+macro_rules! log {
+ (target: $target:expr, $lvl:expr, $($arg:tt)+) => ({
+ static _LOC: $crate::LogLocation = $crate::LogLocation {
+ __line: line!(),
+ __file: file!(),
+ __module_path: module_path!(),
+ };
+ let lvl = $lvl;
+ if lvl <= $crate::__static_max_level() && lvl <= $crate::max_log_level() {
+ $crate::__log(lvl, $target, &_LOC, format_args!($($arg)+))
+ }
+ });
+ ($lvl:expr, $($arg:tt)+) => (log!(target: module_path!(), $lvl, $($arg)+))
+}
+
+/// Logs a message at the error level.
+///
+/// Logging at this level is disabled if the `max_level_off` feature is present.
+#[macro_export]
+macro_rules! error {
+ (target: $target:expr, $($arg:tt)*) => (
+ log!(target: $target, $crate::LogLevel::Error, $($arg)*);
+ );
+ ($($arg:tt)*) => (
+ log!($crate::LogLevel::Error, $($arg)*);
+ )
+}
+
+/// Logs a message at the warn level.
+///
+/// Logging at this level is disabled if any of the following features are
+/// present: `max_level_off` or `max_level_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`.
+#[macro_export]
+macro_rules! warn {
+ (target: $target:expr, $($arg:tt)*) => (
+ log!(target: $target, $crate::LogLevel::Warn, $($arg)*);
+ );
+ ($($arg:tt)*) => (
+ log!($crate::LogLevel::Warn, $($arg)*);
+ )
+}
+
+/// Logs a message at the info level.
+///
+/// Logging at this level is disabled if any of the following features are
+/// present: `max_level_off`, `max_level_error`, or `max_level_warn`.
+///
+/// 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`, `release_max_level_error`, or
+/// `release_max_level_warn`.
+#[macro_export]
+macro_rules! info {
+ (target: $target:expr, $($arg:tt)*) => (
+ log!(target: $target, $crate::LogLevel::Info, $($arg)*);
+ );
+ ($($arg:tt)*) => (
+ log!($crate::LogLevel::Info, $($arg)*);
+ )
+}
+
+/// Logs a message at the debug level.
+///
+/// Logging at this level is disabled if any of the following features are
+/// present: `max_level_off`, `max_level_error`, `max_level_warn`, or
+/// `max_level_info`.
+///
+/// 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`, `release_max_level_error`,
+/// `release_max_level_warn`, or `release_max_level_info`.
+#[macro_export]
+macro_rules! debug {
+ (target: $target:expr, $($arg:tt)*) => (
+ log!(target: $target, $crate::LogLevel::Debug, $($arg)*);
+ );
+ ($($arg:tt)*) => (
+ log!($crate::LogLevel::Debug, $($arg)*);
+ )
+}
+
+/// Logs a message at the trace level.
+///
+/// Logging at this level is disabled if any of the following features are
+/// present: `max_level_off`, `max_level_error`, `max_level_warn`,
+/// `max_level_info`, or `max_level_debug`.
+///
+/// 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`, `release_max_level_error`,
+/// `release_max_level_warn`, `release_max_level_info`, or
+/// `release_max_level_debug`.
+#[macro_export]
+macro_rules! trace {
+ (target: $target:expr, $($arg:tt)*) => (
+ log!(target: $target, $crate::LogLevel::Trace, $($arg)*);
+ );
+ ($($arg:tt)*) => (
+ log!($crate::LogLevel::Trace, $($arg)*);
+ )
+}
+
+/// Determines if a message logged at the specified level in that module will
+/// be logged.
+///
+/// This can be used to avoid expensive computation of log message arguments if
+/// the message would be ignored anyway.
+///
+/// # Examples
+///
+/// ```rust
+/// # #[macro_use]
+/// # extern crate log;
+/// use log::LogLevel::Debug;
+///
+/// # fn foo() {
+/// if log_enabled!(Debug) {
+/// let data = expensive_call();
+/// debug!("expensive debug data: {} {}", data.x, data.y);
+/// }
+/// # }
+/// # struct Data { x: u32, y: u32 }
+/// # fn expensive_call() -> Data { Data { x: 0, y: 0 } }
+/// # fn main() {}
+/// ```
+#[macro_export]
+macro_rules! log_enabled {
+ (target: $target:expr, $lvl:expr) => ({
+ let lvl = $lvl;
+ lvl <= $crate::__static_max_level() && lvl <= $crate::max_log_level() &&
+ $crate::__enabled(lvl, $target)
+ });
+ ($lvl:expr) => (log_enabled!(target: module_path!(), $lvl))
+}