From 1b10e77b0be69337010f96fc45f45f8949b69e26 Mon Sep 17 00:00:00 2001 From: Ben Bangert Date: Sat, 25 Nov 2017 07:45:39 -0800 Subject: [PATCH] feat: use structured logging and log session info out Closes #1055 --- automock/boto.cfg | 2 + autopush/db.py | 3 +- autopush/webpush_server.py | 8 +- autopush_rs/Cargo.lock | 538 +++++++++++++++++++++---------- autopush_rs/Cargo.toml | 20 +- autopush_rs/src/client.rs | 123 ++++++- autopush_rs/src/lib.rs | 13 +- autopush_rs/src/server/mod.rs | 56 +++- autopush_rs/src/util/autojson.rs | 287 +++++++++++++++++ autopush_rs/src/util/mod.rs | 88 +++-- 10 files changed, 896 insertions(+), 242 deletions(-) create mode 100644 autopush_rs/src/util/autojson.rs diff --git a/automock/boto.cfg b/automock/boto.cfg index 318b7a7f..5b1474df 100644 --- a/automock/boto.cfg +++ b/automock/boto.cfg @@ -1,4 +1,5 @@ [default] +endpoint_url = http://localhost:8000 [Boto] is_secure = False @@ -9,3 +10,4 @@ proxy = 127.0.0.1 [DynamoDB] region=us-east-1 validate_checksums=False +endpoint_url = http://localhost:8000 diff --git a/autopush/db.py b/autopush/db.py index 7fee98cd..2940c564 100644 --- a/autopush/db.py +++ b/autopush/db.py @@ -102,7 +102,8 @@ 'dynamodb', config=botocore.config.Config( region_name=os.getenv("AWS_REGION_NAME", "us-east-1") - ) + ), + endpoint_url=os.getenv("AWS_LOCAL_DYNAMODB") ) g_client = g_dynamodb.meta.client diff --git a/autopush/webpush_server.py b/autopush/webpush_server.py index 1c8e6d04..596cfe6e 100644 --- a/autopush/webpush_server.py +++ b/autopush/webpush_server.py @@ -316,10 +316,14 @@ def process_message(self, input): error_msg="Command not found", ) from pprint import pformat - log.info('command: %r %r' % (pformat(command), input)) + log.debug( + 'command: {command} {input}', + command=pformat(command), + input=input + ) command_obj = self.deserialize[command](**input) response = attr.asdict(self.command_dict[command].process(command_obj)) - log.info('response: %s' % response) + log.debug('response: {response}', response=response) return response diff --git a/autopush_rs/Cargo.lock b/autopush_rs/Cargo.lock index 7edf6c92..33555673 100644 --- a/autopush_rs/Cargo.lock +++ b/autopush_rs/Cargo.lock @@ -4,48 +4,64 @@ version = "0.1.0" dependencies = [ "bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "cadence 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.11.7 (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)", - "openssl 0.9.17 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.9.21 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.0.12 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-async 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-json 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-scope 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-stdlog 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-term 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-openssl 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tungstenite 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tungstenite 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tungstenite 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tungstenite 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "woothee 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "aho-corasick" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace-sys" -version = "0.1.12" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -78,7 +94,7 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -89,17 +105,23 @@ dependencies = [ "crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cc" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "cfg-if" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "conv" -version = "0.3.3" +name = "chrono" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -107,11 +129,6 @@ name = "crossbeam" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "custom_derive" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "dbghelp-sys" version = "0.2.0" @@ -139,7 +156,7 @@ name = "error-chain" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -148,24 +165,35 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "futures" -version = "0.1.15" +name = "fuchsia-zircon" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] -name = "futures-cpupool" -version = "0.1.5" +name = "fuchsia-zircon-sys" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "gcc" -version = "0.3.54" +name = "futures" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "futures-cpupool" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "httparse" version = "1.2.3" @@ -173,24 +201,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hyper" -version = "0.11.2" +version = "0.11.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-cpupool 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-cpupool 0.1.7 (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)", - "mime 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "mime 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "relay 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-proto 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -205,16 +234,26 @@ dependencies = [ [[package]] name = "iovec" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "isatty" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "itoa" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -233,7 +272,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lazy_static" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -243,7 +282,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.30" +version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -252,47 +291,38 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "magenta" -version = "0.1.1" +name = "matches" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "conv 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "magenta-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] -name = "magenta-sys" -version = "0.1.1" +name = "memchr" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "matches" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "mime" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicase 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "mio" -version = "0.6.10" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.1 (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.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (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)", - "magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "magenta-sys 0.1.1 (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)", @@ -317,11 +347,38 @@ 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)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "num" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", + "num-iter 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-integer" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-iter" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "num-traits" version = "0.1.40" @@ -329,38 +386,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "num_cpus" -version = "1.6.2" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "openssl" -version = "0.9.17" +version = "0.9.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.17 (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)", + "openssl-sys 0.9.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "openssl-sys" -version = "0.9.17" +version = "0.9.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.3 (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 = "percent-encoding" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -375,11 +432,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rand" -version = "0.3.16" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", - "magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -388,18 +445,35 @@ version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "rustc-demangle" -version = "0.1.5" +name = "regex" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] -name = "rustc_version" -version = "0.1.7" +name = "regex-syntax" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "relay" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustc-demangle" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "safemem" version = "0.2.0" @@ -410,29 +484,24 @@ name = "scoped-tls" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "semver" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "serde" -version = "1.0.14" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_derive" -version = "1.0.14" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive_internals 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive_internals 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive_internals" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -441,13 +510,13 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.3" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -460,6 +529,70 @@ name = "slab" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "slab" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "slog" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "slog-async" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "slog 2.0.12 (registry+https://github.com/rust-lang/crates.io-index)", + "take_mut 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "slog-json" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.0.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "slog-scope" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.0.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "slog-stdlog" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.0.12 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-scope 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "slog-term" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "isatty 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.0.12 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "smallvec" version = "0.2.1" @@ -488,39 +621,62 @@ name = "take" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "take_mut" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "term" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "thread_local" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "time" version = "0.1.38" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-core" -version = "0.1.9" +version = "0.1.10" 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.15 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.11 (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)", + "slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-io" -version = "0.1.3" +version = "0.1.4" 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.15 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -529,10 +685,10 @@ name = "tokio-openssl" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.9.17 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.9.21 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -540,15 +696,15 @@ name = "tokio-proto" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "take 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -557,23 +713,22 @@ name = "tokio-service" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-tungstenite" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tungstenite 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tungstenite 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tungstenite" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -581,18 +736,18 @@ dependencies = [ "bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "utf-8 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "unicase" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -613,14 +768,22 @@ name = "unicode-xid" version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unreachable" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "url" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -631,13 +794,18 @@ dependencies = [ "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "utf8-ranges" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "uuid" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -645,6 +813,16 @@ name = "vcpkg" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "version_check" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "winapi" version = "0.2.8" @@ -655,6 +833,15 @@ name = "winapi-build" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "woothee" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -665,84 +852,105 @@ dependencies = [ ] [metadata] -"checksum backtrace 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "99f2ce94e22b8e664d95c57fff45b98a966c2252b60691d0b7aeeccd88d70983" -"checksum backtrace-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "afccc5772ba333abccdf60d55200fa3406f8c59dcf54d5f7998c9107d3799c7c" +"checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699" +"checksum backtrace 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8709cc7ec06f6f0ae6c2c7e12f6ed41540781f72b488d83734978295ceae182e" +"checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661" "checksum base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96434f987501f0ed4eb336a411e0631ecd1afa11574fe148587adc4ff96143c9" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff81738b726f5d099632ceaffe7fb65b90212e8dce59d518729e7e8634032d3d" "checksum bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d828f97b58cc5de3e40c421d0cf2132d6b2da4ee0e11b8632fa838f0f9333ad6" "checksum cadence 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b48d3db3b2321bc9275c142fa2ddf04d2bcaa651a3b2acfaf8f4a1919402c88e" +"checksum cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a9b13a57efd6b30ecd6598ebdb302cca617930b5470647570468a65d12ef9719" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" -"checksum conv 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "78ff10625fd0ac447827aa30ea8b861fead473bb60aeb73af6c1c58caf0d1299" +"checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9" "checksum crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0c5ea215664ca264da8a9d9c3be80d2eaf30923c259d03e870388eb927508f97" -"checksum custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9" "checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" "checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" "checksum foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e4056b9bd47f8ac5ba12be771f77a0dae796d1bbaaf5fd0b9c2d38b69b8a29d" -"checksum futures 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a82bdc62350ca9d7974c760e9665102fc9d740992a528c2254aa930e53b783c4" -"checksum futures-cpupool 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a283c84501e92cade5ea673a2a7ca44f71f209ccdd302a3e0896f50083d2c5ff" -"checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" +"checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159" +"checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82" +"checksum futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "118b49cac82e04121117cbd3121ede3147e885627d82c4546b87c702debb90c1" +"checksum futures-cpupool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e86f49cc0d92fe1b97a5980ec32d56208272cbb00f15044ea9e2799dde766fdf" "checksum httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "af2f2dd97457e8fb1ae7c5a420db346af389926e36f43768b96f101546b04a07" -"checksum hyper 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "641abc3e3fcf0de41165595f801376e01106bca1fd876dda937730e477ca004c" +"checksum hyper 0.11.7 (registry+https://github.com/rust-lang/crates.io-index)" = "4959ca95f55df4265bff2ad63066147255e6fa733682cf6d1cb5eaff6e53324b" "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" -"checksum iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "29d062ee61fccdf25be172e70f34c9f6efc597e1fb8f6526e8437b2046ab26be" -"checksum itoa 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ac17257442c2ed77dbc9fd555cf83c58b0c7f7d0e8f2ae08c0ac05c72842e1f6" +"checksum iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6e8b9c2247fcf6c6a1151f1156932be5606c9fd6f55a2d7f9fc1cb29386b2f7" +"checksum isatty 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "00c9301a947a2eaee7ce2556b80285dcc89558d07088962e6e8b9c25730f9dc6" +"checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" -"checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" +"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3b585b7a6811fb03aa10e74b278a0f00f8dd9b45dc681f148bb29fa5cb61859b" -"checksum libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)" = "2370ca07ec338939e356443dac2296f581453c35fe1e3a3ed06023c49435f915" +"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2" "checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b" -"checksum magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf0336886480e671965f794bc9b6fce88503563013d1bfb7a502c81fe3ac527" -"checksum magenta-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40d014c7011ac470ae28e2f76a02bfea4a8480f73e701353b49ad7a8d75f4699" "checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376" -"checksum mime 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "153f98dde2b135dece079e5478ee400ae1bab13afa52d66590eacfc40e912435" -"checksum mio 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "dbd91d3bfbceb13897065e97b2ef177a09a438cb33612b2d371bf568819a9313" +"checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a" +"checksum mime 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e2e00e17be181010a91dbfefb01660b17311059dc8c7f48b9017677721e732bd" +"checksum mio 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0e8411968194c7b139e9105bc4ae7db0bae232af087147e72f0616ebf5fdb9cb" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)" = "3a80f842784ef6c9a958b68b7516bc7e35883c614004dd94959a4dca1b716c09" +"checksum num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "a311b77ebdc5dd4cf6449d81e4135d9f0e3b153839ac90e648a8ef538f923525" +"checksum num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "d1452e8b06e448a07f0e6ebb0bb1d92b8890eea63288c0b627331d53514d0fba" +"checksum num-iter 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)" = "7485fcc84f85b4ecd0ea527b14189281cf27d60e583ae65ebc9c088b13dffe01" "checksum num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "99843c856d68d8b4313b03a17e33c4bb42ae8f6610ea81b28abe076ac721b9b0" -"checksum num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aec53c34f2d0247c5ca5d32cca1478762f301740468ee9ee6dcb7a0dd7a0c584" -"checksum openssl 0.9.17 (registry+https://github.com/rust-lang/crates.io-index)" = "085aaedcc89a2fac1eb2bc19cd66f29d4ea99fec60f82a5f3a88a6be7dbd90b5" -"checksum openssl-sys 0.9.17 (registry+https://github.com/rust-lang/crates.io-index)" = "7e3a9845a4c9fdb321931868aae5549e96bb7b979bf9af7de03603d74691b5f3" -"checksum percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de154f638187706bde41d9b4738748933d64e6b37bdbffc0b47a97d16a6ae356" +"checksum num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "514f0d73e64be53ff320680ca671b64fe3fb91da01e1ae2ddc99eb51d453b20d" +"checksum openssl 0.9.21 (registry+https://github.com/rust-lang/crates.io-index)" = "2225c305d8f57001a0d34263e046794aa251695f20773102fbbfeb1e7b189955" +"checksum openssl-sys 0.9.21 (registry+https://github.com/rust-lang/crates.io-index)" = "92867746af30eea7a89feade385f7f5366776f1c52ec6f0de81360373fa88363" +"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" -"checksum rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "eb250fd207a4729c976794d03db689c9be1d634ab5a1c9da9492a13d8fecbcdf" +"checksum rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6475140dfd8655aeb72e1fd4b7a1cc1c202be65d71669476e392fe62532b9edd" "checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509" +"checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b" +"checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db" +"checksum relay 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f301bafeb60867c85170031bdb2fcf24c8041f33aee09e7b116a58d4e9f781c5" "checksum rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aee45432acc62f7b9a108cc054142dac51f979e69e71ddce7d6fc7adf29e817e" -"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" "checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" "checksum scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f417c22df063e9450888a7561788e9bd46d3bb3c1466435b4eccb903807f147d" -"checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" -"checksum serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "bcb6a7637a47663ee073391a139ed07851f27ed2532c2abc88c6bf27a16cdf34" -"checksum serde_derive 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "812ff66056fd9a9a5b7c119714243b0862cf98340e7d4b5ee05a932c40d5ea6c" -"checksum serde_derive_internals 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd381f6d01a6616cdba8530492d453b7761b456ba974e98768a18cad2cd76f58" -"checksum serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d243424e06f9f9c39e3cd36147470fd340db785825e367625f79298a6ac6b7ac" +"checksum serde 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6eda663e865517ee783b0891a3f6eb3a253e0b0dabb46418969ee9635beadd9e" +"checksum serde_derive 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)" = "652bc323d694dc925829725ec6c890156d8e70ae5202919869cb00fe2eff3788" +"checksum serde_derive_internals 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "32f1926285523b2db55df263d2aa4eb69ddcfa7a7eade6430323637866b513ab" +"checksum serde_json 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e4586746d1974a030c48919731ecffd0ed28d0c40749d0d18d43b3a7d6c9b20e" "checksum sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cc30b1e1e8c40c121ca33b86c23308a090d19974ef001b4bf6e61fd1a0fb095c" "checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" +"checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d" +"checksum slog 2.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "717c886b5e7855cf2e434a2d73ff494d33aaa584fb48e3074affc7b66dcd290d" +"checksum slog-async 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ad0c2eeab552a206f95303868338aa67041146da8f8978dba8343c2b29b8ec2" +"checksum slog-json 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0e353935432798202079041c6ef6cd0d70a9d5123637a21512a648fcfa8da3fc" +"checksum slog-scope 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd3236e1818c147ed3003930289dc6457425aaca3a7dbb6b7f3032f075d865c5" +"checksum slog-stdlog 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ac42f8254ae996cc7d640f9410d3b048dcdf8887a10df4d5d4c44966de24c4a8" +"checksum slog-term 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5bb5d9360b2b279b326824b3b4ca2402ead8a8138f0e5ec1900605c861bb6671" "checksum smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c8cbcd6df1e117c2210e13ab5109635ad68a929fcbb8964dc965b76cb5ee013" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum take 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b157868d8ac1f56b64604539990685fa7611d8fa9e5476cf0c02cf34d32917c5" +"checksum take_mut 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7986ceb18a0d75e1fcb8b27c0119389bbe05f016e5a6e54d003251acc1122108" +"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" +"checksum thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1697c4b57aeeb7a536b647165a2825faddffb1d3bad386d507709bd51a90bb14" "checksum time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "d5d788d3aa77bc0ef3e9621256885555368b47bd495c13dd2e7413c89f845520" -"checksum tokio-core 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e85d419699ec4b71bfe35bbc25bb8771e52eff0471a7f75c853ad06e200b4f86" -"checksum tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4ab83e7adb5677e42e405fa4ceff75659d93c4d7d7dd22f52fcec59ee9f02af" +"checksum tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "c843a027f7c1df5f81e7734a0df3f67bf329411781ebf36393ce67beef6071e3" +"checksum tokio-io 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "514aae203178929dbf03318ad7c683126672d4d96eccb77b29603d33c9e25743" "checksum tokio-openssl 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "364cd119c3aec80ebf74e7362e65c4659dbec9fb8fc6c6875c5b28e95bd2b168" "checksum tokio-proto 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fbb47ae81353c63c487030659494b295f6cb6576242f907f203473b191b0389" "checksum tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" -"checksum tokio-tungstenite 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "20b4fa778e8d6d6f7c53fc097f2a5c2f3460fa5e5703d28c61309f63420f1f0b" -"checksum tungstenite 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "366c5dd8da77368bad71bb1977cfe8af094d03b87765c12d1422e2f0785afb22" -"checksum unicase 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e01da42520092d0cd2d6ac3ae69eb21a22ad43ff195676b86f8c37f487d6b80" +"checksum tokio-tungstenite 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2495ad09630cddb7189e0b9e6ade3d0893e9447388077c9cd69e7d1f9b1e9eeb" +"checksum tungstenite 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2b85687de275b2b6573fdfcfe909f899eb4ebfe34c28911ff01df45cd81d26fe" +"checksum unicase 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "284b6d3db520d67fbe88fd778c21510d1b0ba4a551e5d0fbb023d33405f6de8a" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "51ccda9ef9efa3f7ef5d91e8f9b83bbe6955f9bf86aec89d5cce2c874625920f" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" -"checksum url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb819346883532a271eb626deb43c4a1bb4c4dd47c519bd78137c3e72a4fe27" +"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" +"checksum url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa35e768d4daf1d85733418a49fb42e10d7f633e394fccab4ab7aba897053fe2" "checksum utf-8 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6f923c601c7ac48ef1d66f7d5b5b2d9a7ba9c51333ab75a3ddf8d0309185a56" +"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" "checksum uuid 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc7e3b898aa6f6c08e5295b6c89258d1331e9ac578cc992fb818759951bdc22" "checksum vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9e0a7d8bed3178a8fb112199d466eeca9ed09a14ba8ad67718179b4fd5487d0b" +"checksum version_check 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6b772017e347561807c1aa192438c5fd74242a670a6cffacc40f2defd1dc069d" +"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum woothee 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e7c2cece51be2a2f25518a9efdd303d5ca8dfa619272f091e7dedbba95d1873" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" diff --git a/autopush_rs/Cargo.toml b/autopush_rs/Cargo.toml index b4ff23bf..c60a10eb 100644 --- a/autopush_rs/Cargo.toml +++ b/autopush_rs/Cargo.toml @@ -9,22 +9,36 @@ crate-type = ["cdylib"] [dependencies] bytes = "0.4" cadence = "0.12.1" +chrono = "0.4" env_logger = { version = "0.4", default-features = false } error-chain = "0.10" futures = "0.1" httparse = "1.0" hyper = "0.11" libc = "0.2" -log = "0.3" +# log: Use this version for debug builds +#log = "0.3" +# log: Use this for release builds (leave in for commits) +log = { version = "0.3", features = ["max_level_trace", "release_max_level_warn"] } openssl = "0.9" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" +# slog: Use this first version for debug builds +#slog = { version = "2.0.12" , features = ["max_level_trace", "release_max_level_debug"] } +# slog: Use this for release builds (leave in for commits) +slog = "2.0.12" +slog-async = "2.1.0" +slog-term = "2.3.0" +slog-json = "2.0.2" +slog-scope = "4.0.0" +slog-stdlog = "3.0.2" time = "0.1" tokio-core = "0.1" tokio-io = "0.1" tokio-openssl = "0.1" tokio-service = "0.1" -tokio-tungstenite = { version = "0.3", default-features = false } -tungstenite = { version = "0.4", default-features = false } +tokio-tungstenite = { version = "0.4", default-features = false } +tungstenite = { version = "0.5", default-features = false } uuid = { version = "0.5", features = ["serde", "v4"] } +woothee = "0.7.3" diff --git a/autopush_rs/src/client.rs b/autopush_rs/src/client.rs index f3ae5110..3450f300 100644 --- a/autopush_rs/src/client.rs +++ b/autopush_rs/src/client.rs @@ -11,10 +11,12 @@ use cadence::prelude::*; use futures::AsyncSink; use futures::future::Either; use futures::sync::mpsc; +use futures::sync::oneshot::Receiver; use futures::{Stream, Sink, Future, Poll, Async}; use tokio_core::reactor::Timeout; use time; use uuid::Uuid; +use woothee::parser::{Parser, WootheeResult}; use call; use errors::*; @@ -26,6 +28,26 @@ pub struct RegisteredClient { pub tx: mpsc::UnboundedSender, } +// Websocket session statistics +#[derive(Clone)] +struct SessionStatistics { + // User data + uaid: String, + uaid_reset: bool, + existing_uaid: bool, + connection_type: String, + host: String, + + // Usage data + direct_acked: i32, + direct_storage: i32, + stored_retrieved: i32, + stored_acked: i32, + nacks: i32, + unregisters: i32, + registers: i32, +} + // Represents a websocket client connection that may or may not be authenticated pub struct Client { data: ClientData, @@ -36,6 +58,8 @@ pub struct ClientData { webpush: Option, srv: Rc, ws: T, + user_agent: String, + host: String, } // Represent the state for a valid WebPush client that is authenticated @@ -50,6 +74,7 @@ pub struct WebPushClient { // when all the unacked storeds are ack'd unacked_stored_highest: Option, connected_at: u64, + stats: SessionStatistics, } impl WebPushClient { @@ -128,15 +153,31 @@ where /// the various state behind the server. This provides transitive access to /// various configuration options of the server as well as the ability to /// call back into Python. - pub fn new(ws: T, srv: &Rc) -> Client { + pub fn new(ws: T, srv: &Rc, mut uarx: Receiver, host: String) -> Client { let srv = srv.clone(); let timeout = Timeout::new(srv.opts.open_handshake_timeout.unwrap(), &srv.handle).unwrap(); + + // Pull out the user-agent, which we should have by now + let uastr = match uarx.poll() { + Ok(Async::Ready(ua)) => ua, + Ok(Async::NotReady) => { + error!("Failed to parse the user-agent"); + String::from("") + } + Err(_) => { + error!("Failed to receive a value"); + String::from("") + } + }; + Client { state: ClientState::WaitingForHello(timeout), data: ClientData { webpush: None, srv: srv.clone(), ws: ws, + user_agent: uastr, + host, }, } } @@ -310,6 +351,7 @@ where debug!("State: WaitingForRegister"); let msg = match try_ready!(response.poll()) { call::RegisterResponse::Success { endpoint } => { + self.data.webpush.as_mut().unwrap().stats.registers += 1; ServerMessage::Register { channel_id: channel_id, status: 200, @@ -337,6 +379,7 @@ where let msg = match try_ready!(response.poll()) { call::UnRegisterResponse::Success { success } => { debug!("Got the unregister response"); + self.data.webpush.as_mut().unwrap().stats.unregisters += 1; ServerMessage::Unregister { channel_id: channel_id, status: if success { 200 } else { 500 }, @@ -489,15 +532,30 @@ where flags.check = check_storage; flags.reset_uaid = reset_uaid; flags.rotate_message_table = rotate_message_table; + self.webpush = Some(WebPushClient { - uaid: uaid, - flags: flags, - rx: rx, - message_month: message_month, + uaid, + flags, + rx, + message_month, unacked_direct_notifs: Vec::new(), unacked_stored_notifs: Vec::new(), unacked_stored_highest: None, - connected_at: connected_at, + connected_at, + stats: SessionStatistics { + uaid: uaid.hyphenated().to_string(), + uaid_reset: reset_uaid, + existing_uaid: check_storage, + connection_type: String::from("webpush"), + host: String::from("unknown"), + direct_acked: 0, + direct_storage: 0, + stored_retrieved: 0, + stored_acked: 0, + nacks: 0, + registers: 0, + unregisters: 0, + }, }); self.srv.connect_client( RegisteredClient { uaid: uaid, tx: tx }, @@ -511,7 +569,7 @@ where } fn process_register(&mut self, channel_id: Uuid, key: Option) -> ClientState { - debug!("Got a register command"); + debug!("Got a register command"; "channel_id" => channel_id.hyphenated().to_string()); let webpush = self.webpush.as_ref().unwrap(); let uaid = webpush.uaid.clone(); let message_month = webpush.message_month.clone(); @@ -549,6 +607,7 @@ where v.channel_id == notif.channel_id && v.version == notif.version }) { + webpush.stats.direct_acked += 1; webpush.unacked_direct_notifs.remove(pos); continue; }; @@ -556,6 +615,7 @@ where v.channel_id == notif.channel_id && v.version == notif.version }) { + webpush.stats.stored_acked += 1; let message_month = webpush.message_month.clone(); let n = webpush.unacked_stored_notifs.remove(pos); if n.topic.is_some() { @@ -618,7 +678,10 @@ where // If there's direct unack'd messages, they need to be saved out without blocking // here self.srv.disconnet_client(&webpush.uaid); - if webpush.unacked_direct_notifs.len() > 0 { + let mut stats = webpush.stats.clone(); + let unacked_direct_notifs = webpush.unacked_direct_notifs.len(); + if unacked_direct_notifs > 0 { + stats.direct_storage += unacked_direct_notifs as i32; self.srv.handle.spawn( self.srv .store_messages( @@ -632,6 +695,50 @@ where }), ) } + + // Parse the user-agent string + let parser = Parser::new(); + let ua_result = parser.parse(self.user_agent.as_str()); + let mut ua_os_family = String::new(); + let mut ua_os_ver = String::new(); + let mut ua_browser_family = String::new(); + let mut ua_browser_ver = String::new(); + let mut ua_name = String::new(); + let mut ua_category = String::new(); + match ua_result { + Some(WootheeResult { name, os, os_version, version, vendor, category, .. }) => { + ua_name = String::from(name); + ua_os_family = String::from(os); + ua_os_ver = os_version; + ua_browser_family = String::from(vendor); + ua_browser_ver = version; + ua_category = String::from(category); + } + None => () + }; + + // Log out the final stats message + info!("Session"; + "uaid_hash" => stats.uaid.as_str(), + "uaid_reset" => stats.uaid_reset, + "existing_uaid" => stats.existing_uaid, + "connection_type" => stats.connection_type.as_str(), + "host" => self.host.clone(), + "ua_name" => ua_name.as_str(), + "ua_os_family" => ua_os_family.as_str(), + "ua_os_ver" => ua_os_ver.as_str(), + "ua_browser_family" => ua_browser_family.as_str(), + "ua_browser_ver" => ua_browser_ver.as_str(), + "ua_category" => ua_category.as_str(), + "connection_time" => elapsed, + "direct_acked" => stats.direct_acked, + "direct_storage" => stats.direct_storage, + "stored_retrieved" => stats.stored_retrieved, + "stored_acked" => stats.stored_acked, + "nacks" => stats.nacks, + "registers" => stats.registers, + "unregisters" => stats.unregisters, + ); }; } } diff --git a/autopush_rs/src/lib.rs b/autopush_rs/src/lib.rs index 6799bf10..a17e1ae3 100644 --- a/autopush_rs/src/lib.rs +++ b/autopush_rs/src/lib.rs @@ -62,19 +62,25 @@ extern crate bytes; extern crate cadence; -extern crate env_logger; +extern crate chrono; #[macro_use] extern crate futures; extern crate httparse; extern crate hyper; extern crate libc; -#[macro_use] -extern crate log; extern crate openssl; extern crate serde; #[macro_use] extern crate serde_derive; #[macro_use] +extern crate slog; +#[macro_use] +extern crate slog_scope; +extern crate slog_term; +extern crate slog_async; +extern crate slog_json; +extern crate slog_stdlog; +#[macro_use] extern crate serde_json; extern crate time; extern crate tokio_core; @@ -84,6 +90,7 @@ extern crate tokio_service; extern crate tokio_tungstenite; extern crate tungstenite; extern crate uuid; +extern crate woothee; #[macro_use] extern crate error_chain; diff --git a/autopush_rs/src/server/mod.rs b/autopush_rs/src/server/mod.rs index 66e22c0a..1c864a52 100644 --- a/autopush_rs/src/server/mod.rs +++ b/autopush_rs/src/server/mod.rs @@ -21,12 +21,14 @@ use time; use tokio_core::net::TcpListener; use tokio_core::reactor::{Core, Timeout, Handle}; use tokio_io; -use tokio_tungstenite::{accept_async, WebSocketStream}; +use tokio_tungstenite::{accept_hdr_async, WebSocketStream}; +use tungstenite::handshake::server::Request; use tungstenite::Message; use uuid::Uuid; use client::{Client, RegisteredClient}; use errors::*; +use errors::{Error, Result}; use protocol::{ClientMessage, ServerMessage, ServerNotification, Notification}; use queue::{self, AutopushQueue}; use rt::{self, AutopushError, UnwindGuard}; @@ -40,6 +42,8 @@ mod metrics; mod tls; mod webpush_io; +const UAHEADER: &str = "User-Agent"; + #[repr(C)] pub struct AutopushServer { inner: UnwindGuard, @@ -100,6 +104,7 @@ pub struct ServerOptions { pub close_handshake_timeout: Option, pub statsd_host: Option, pub statsd_port: u16, + pub logger: util::LogGuards, } fn resolve(host: &str) -> IpAddr { @@ -141,8 +146,11 @@ pub extern "C" fn autopush_server_new( rt::catch(err, || unsafe { let opts = &*opts; - util::init_logging(opts.json_logging != 0); + let hostname = to_s(opts.host_ip) + .expect("hostname must be specified") + .as_ref(); + let logger = util::init_logging(opts.json_logging != 0, hostname); let opts = ServerOptions { debug: opts.debug != 0, host_ip: to_s(opts.host_ip) @@ -170,6 +178,7 @@ pub extern "C" fn autopush_server_new( Some(opts.max_connections) }, open_handshake_timeout: ito_dur(opts.open_handshake_timeout), + logger: logger, }; Box::new(AutopushServer { @@ -256,8 +265,7 @@ impl Server { Err(e) => return inittx.send(Some(e)).unwrap(), }; - // For now during development spin up a dummy HTTP server which is - // used to send notifications to clients. + // Internal HTTP server setup { use hyper::server::Http; @@ -273,7 +281,7 @@ impl Server { Ok(()) }); core.handle().spawn(push_srv.then(|res| { - info!("Http server {:?}", res); + debug!("Http server {:?}", res); Ok(()) })); } @@ -335,14 +343,32 @@ impl Server { let request = timeout(request, srv.opts.open_handshake_timeout, &handle); let srv2 = srv.clone(); let handle2 = handle.clone(); + + let host = format!("{}", addr.ip()); + + // Setup oneshot to extract the user-agent from the header callback + let (uatx, uarx) = oneshot::channel(); + let callback = |req: &Request| { + if let Some(value) = req.headers.find_first(UAHEADER) { + let mut valstr = String::new(); + for c in value.iter() { + let c = *c as char; + valstr.push(c); + } + debug!("Found user-agent string"; "user-agent" => valstr.as_str()); + uatx.send(valstr).unwrap(); + } + debug!("No agent string found"); + Ok(None) + }; + let client = request.and_then(move |(socket, request)| -> MyFuture<_> { match request { RequestType::Status => write_status(socket), RequestType::Websocket => { // Perform the websocket handshake on each // connection, but don't let it take too long. - let ws = - accept_async(socket, None).chain_err(|| "failed to accept client"); + let ws = accept_hdr_async(socket, callback).chain_err(|| "failed to accept client"); let ws = timeout(ws, srv2.opts.open_handshake_timeout, &handle2); // Once the handshake is done we'll start the main @@ -351,7 +377,7 @@ impl Server { // the internal state machine. Box::new( ws.and_then(move |ws| { - PingManager::new(&srv2, ws).chain_err( + PingManager::new(&srv2, ws, uarx, host).chain_err( || "failed to make ping handler", ) }).flatten(), @@ -369,7 +395,7 @@ impl Server { error.push_str("\n"); error.push_str(&err.to_string()); } - error!("{}: {}", addr, error); + debug!("{}: {}", addr, error); } Ok(()) })); @@ -409,7 +435,7 @@ impl Server { .tx .unbounded_send(ServerNotification::Notification(notif)) .unwrap(); - info!("Dropped notification in queue"); + debug!("Dropped notification in queue"); return Ok(()); } Err("User not connected".into()) @@ -450,7 +476,12 @@ enum CloseState { } impl PingManager { - fn new(srv: &Rc, socket: WebSocketStream) -> io::Result { + fn new( + srv: &Rc, + socket: WebSocketStream, + uarx: oneshot::Receiver, + host: String) + -> io::Result { // The `socket` is itself a sink and a stream, and we've also got a sink // (`tx`) and a stream (`rx`) to send messages. Half of our job will be // doing all this proxying: reading messages from `socket` and sending @@ -470,7 +501,7 @@ impl PingManager { timeout: Timeout::new(srv.opts.auto_ping_interval, &srv.handle)?, waiting: WaitingFor::SendPing, socket: socket.clone(), - client: CloseState::Exchange(Client::new(socket, srv)), + client: CloseState::Exchange(Client::new(socket, srv, uarx, host)), srv: srv.clone(), }) } @@ -540,6 +571,7 @@ impl Future for PingManager { if let CloseState::Exchange(ref mut client) = self.client { client.shutdown(); } + // So did the shutdown not work? We must call shutdown but no client here? return Err("close handshake took too long".into()); } } diff --git a/autopush_rs/src/util/autojson.rs b/autopush_rs/src/util/autojson.rs new file mode 100644 index 00000000..1f0c8039 --- /dev/null +++ b/autopush_rs/src/util/autojson.rs @@ -0,0 +1,287 @@ +// {{{ Crate docs +//! JSON `Drain` for `slog-rs` +//! +//! ``` +//! #[macro_use] +//! extern crate slog; +//! extern crate slog_json; +//! +//! use slog::Drain; +//! use std::sync::Mutex; +//! +//! fn main() { +//! let root = slog::Logger::root( +//! Mutex::new(slog_json::Json::default(std::io::stderr())).map(slog::Fuse), +//! o!("version" => env!("CARGO_PKG_VERSION")) +//! ); +//! } +//! ``` +// }}} +use chrono; +use serde; +use serde_json; +use serde::ser::SerializeMap; +use slog; +use slog::{FnValue, PushFnValue}; +use slog::{OwnedKVList, KV, SendSyncRefUnwindSafeKV}; +use slog::Record; +use std; +use std::{io, result, fmt}; +use std::io::Cursor; + +use std::cell::RefCell; +use std::fmt::Write; + +// }}} + +// {{{ Serialize +thread_local! { + static TL_BUF: RefCell = RefCell::new(String::with_capacity(128)) +} + +/// `slog::Serializer` adapter for `serde::Serializer` +/// +/// Newtype to wrap serde Serializer, so that `Serialize` can be implemented +/// for it +struct SerdeSerializer { + /// Current state of map serializing: `serde::Seriaizer::MapState` + ser_map: S::SerializeMap, +} + +impl SerdeSerializer { + /// Start serializing map of values + fn start(ser: S, len: Option) -> result::Result { + let ser_map = try!(ser.serialize_map(len) + .map_err(|_| { + io::Error::new(io::ErrorKind::Other, + "serde serialization error") + })); + Ok(SerdeSerializer { ser_map: ser_map }) + } + + /// Finish serialization, and return the serializer + fn end(self) -> std::result::Result { + self.ser_map.end() + } +} + +macro_rules! impl_m( + ($s:expr, $key:expr, $val:expr) => ({ + try!($s.ser_map.serialize_entry($key, $val) + .map_err(|_| io::Error::new(io::ErrorKind::Other, "serde serialization error"))); + Ok(()) + }); +); + +impl slog::Serializer for SerdeSerializer + where S: serde::Serializer +{ + fn emit_bool(&mut self, key: &str, val: bool) -> slog::Result { + impl_m!(self, key, &val) + } + + fn emit_unit(&mut self, key: &str) -> slog::Result { + impl_m!(self, key, &()) + } + + fn emit_char(&mut self, key: &str, val: char) -> slog::Result { + impl_m!(self, key, &val) + } + + fn emit_none(&mut self, key: &str) -> slog::Result { + let val: Option<()> = None; + impl_m!(self, key, &val) + } + fn emit_u8(&mut self, key: &str, val: u8) -> slog::Result { + impl_m!(self, key, &val) + } + fn emit_i8(&mut self, key: &str, val: i8) -> slog::Result { + impl_m!(self, key, &val) + } + fn emit_u16(&mut self, key: &str, val: u16) -> slog::Result { + impl_m!(self, key, &val) + } + fn emit_i16(&mut self, key: &str, val: i16) -> slog::Result { + impl_m!(self, key, &val) + } + fn emit_usize(&mut self, key: &str, val: usize) -> slog::Result { + impl_m!(self, key, &val) + } + fn emit_isize(&mut self, key: &str, val: isize) -> slog::Result { + impl_m!(self, key, &val) + } + fn emit_u32(&mut self, key: &str, val: u32) -> slog::Result { + impl_m!(self, key, &val) + } + fn emit_i32(&mut self, key: &str, val: i32) -> slog::Result { + impl_m!(self, key, &val) + } + fn emit_f32(&mut self, key: &str, val: f32) -> slog::Result { + impl_m!(self, key, &val) + } + fn emit_u64(&mut self, key: &str, val: u64) -> slog::Result { + impl_m!(self, key, &val) + } + fn emit_i64(&mut self, key: &str, val: i64) -> slog::Result { + impl_m!(self, key, &val) + } + fn emit_f64(&mut self, key: &str, val: f64) -> slog::Result { + impl_m!(self, key, &val) + } + fn emit_str(&mut self, key: &str, val: &str) -> slog::Result { + impl_m!(self, key, &val) + } + fn emit_arguments(&mut self, + key: &str, + val: &fmt::Arguments) + -> slog::Result { + TL_BUF.with(|buf| { + let mut buf = buf.borrow_mut(); + + buf.write_fmt(*val).unwrap(); + + let res = { + || impl_m!(self, key, &*buf) + }(); + buf.clear(); + res + }) + } +} +// }}} + +// {{{ Json +/// Json `Drain` +/// +/// Each record will be printed as a Json map +/// to a given `io` +pub struct AutoJson { + values: Vec, + io: RefCell, +} + +impl AutoJson + where W: io::Write +{ + /// Build custom `Json` `Drain` + #[cfg_attr(feature = "cargo-clippy", allow(new_ret_no_self))] + pub fn new(io: W) -> AutoJsonBuilder { + AutoJsonBuilder::new(io) + } +} + +// }}} + +// {{{ JsonBuilder +/// Json `Drain` builder +/// +/// Create with `Json::new`. +pub struct AutoJsonBuilder { + values: Vec, + io: W, +} + +impl AutoJsonBuilder + where W: io::Write +{ + fn new(io: W) -> Self { + AutoJsonBuilder { + values: vec![], + io, + } + } + + /// Build `Json` `Drain` + /// + /// This consumes the builder. + pub fn build(self) -> AutoJson { + AutoJson { + values: self.values, + io: RefCell::new(self.io), + } + } + + /// Add custom values to be printed with this formatter + pub fn add_key_value(mut self, value: slog::OwnedKV) -> Self + where T: SendSyncRefUnwindSafeKV + 'static + { + self.values.push(value.into()); + self + } + + /// Add default key-values: + /// + /// * `ts` - timestamp + /// * `level` - record logging level name + /// * `msg` - msg - formatted logging message + pub fn add_default_keys(self) -> Self { + self.add_key_value(o!( + "Timestamp" => PushFnValue(move |_ : &Record, ser| { + let now = chrono::Utc::now(); + let nsec: i64 = (now.timestamp() as i64) * 1_000_000_000; + let nsec: i64 = nsec + (now.timestamp_subsec_nanos() as i64); + ser.emit(nsec) + }), + "Severity" => FnValue(move |rinfo : &Record| { + if rinfo.level() == slog::Level::Error { + 3 + } else { + 5 + } + }) + )) + } +} + +impl slog::Drain for AutoJson + where W: io::Write +{ + type Ok = (); + type Err = io::Error; + fn log(&self, + rinfo: &Record, + logger_values: &OwnedKVList) + -> io::Result<()> { + + // XXX: UGLY HACK HERE + // First write out the structure without the Fields nested + let mut buff = Cursor::new(Vec::new()); + { + let mut serializer = serde_json::Serializer::new(&mut buff); + let mut serializer = + SerdeSerializer::start(&mut serializer, None)?; + for kv in &self.values { + kv.serialize(rinfo, &mut serializer)?; + } + logger_values.serialize(rinfo, &mut serializer)?; + let fields_placeholder = kv!("Fields" => "00PLACEHOLDER00"); + fields_placeholder.serialize(rinfo, &mut serializer)?; + let res = serializer.end(); + res.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; + }; + let payload = String::from_utf8(buff.into_inner()).unwrap(); + + // Now write out just the Fields entry we replace with + let mut buff = Cursor::new(Vec::new()); + { + let mut serializer = serde_json::Serializer::new(&mut buff); + let mut serializer = + SerdeSerializer::start(&mut serializer, None)?; + let msg = kv!("message" => format!("{}", rinfo.msg())); + msg.serialize(rinfo, &mut serializer)?; + rinfo.kv().serialize(rinfo, &mut serializer)?; + }; + let message = String::from_utf8(buff.into_inner()).unwrap(); + + // And now we replace the placeholder with the contents + let mut payload = payload.replace("\"00PLACEHOLDER00\"", message.as_str()); + // For some reason the replace loses an end } + payload.push_str("}"); + + let mut io = self.io.borrow_mut(); + io.write_all(payload.as_bytes())?; + io.write_all("\n".as_bytes())?; + Ok(()) + } +} +// }}} diff --git a/autopush_rs/src/util/mod.rs b/autopush_rs/src/util/mod.rs index c1cd09e7..5bd340b5 100644 --- a/autopush_rs/src/util/mod.rs +++ b/autopush_rs/src/util/mod.rs @@ -1,18 +1,21 @@ //! Various small utilities accumulated over time for the WebPush server -use std::env; +use std::io; use std::time::Duration; -use std::sync::atomic::{ATOMIC_BOOL_INIT, AtomicBool, Ordering}; -use env_logger; use futures::future::{Either, Future, IntoFuture}; -use log::LogRecord; -use serde_json; +use slog; +use slog_async; +use slog_term; +use slog_scope; +use slog_stdlog; +use slog::Drain; use tokio_core::reactor::{Handle, Timeout}; use errors::*; mod send_all; mod rc; +mod autojson; pub use self::send_all::MySendAll; pub use self::rc::RcObject; @@ -41,52 +44,41 @@ where })) } -static LOG_JSON: AtomicBool = ATOMIC_BOOL_INIT; -pub fn init_logging(json: bool) { - // We only initialize once, so ignore initialization errors related to - // calling this function twice. - let mut builder = env_logger::LogBuilder::new(); - - if env::var("RUST_LOG").is_ok() { - builder.parse(&env::var("RUST_LOG").unwrap()); - } - - builder.target(env_logger::LogTarget::Stdout).format( - maybe_json_record, - ); - - if builder.init().is_ok() { - LOG_JSON.store(json, Ordering::SeqCst); - } +// Hold a reference to the log guards for scoped logging which requires these to stay alive +// for the implicit logger to be passed into logging calls +pub struct LogGuards { + _scope_guard: slog_scope::GlobalLoggerGuard, } -fn maybe_json_record(record: &LogRecord) -> String { - #[derive(Serialize)] - struct Message<'a> { - msg: String, - level: String, - target: &'a str, - module: &'a str, - file: &'a str, - line: u32, - } - - if LOG_JSON.load(Ordering::SeqCst) { - serde_json::to_string(&Message { - msg: record.args().to_string(), - level: record.level().to_string(), - target: record.target(), - module: record.location().module_path(), - file: record.location().file(), - line: record.location().line(), - }).unwrap() +pub fn init_logging(json: bool, hostname: &'static str) -> LogGuards { + let decorator = slog_term::TermDecorator::new().build(); + if json { + let drain = autojson::AutoJson::new(io::stdout()) + .add_default_keys() + .add_key_value(o!( + "Hostname" => hostname, + "Type" => "autopush_rs:log", + "EnvVersion" => "2.0", + "Logger" => format!("AutopushRust-{}", env!("CARGO_PKG_VERSION")), + )) + .build() + .fuse(); + let drain = slog_async::Async::new(drain).build().fuse(); + let logger = slog::Logger::root(drain, o!()); + let _scope_guard = slog_scope::set_global_logger(logger); + slog_stdlog::init().ok(); + LogGuards { + _scope_guard: _scope_guard, + } } else { - format!( - "{}:{}: {}", - record.level(), - record.location().module_path(), - record.args() - ) + let drain = slog_term::FullFormat::new(decorator).build().fuse(); + let drain = slog_async::Async::new(drain).build().fuse(); + let logger = slog::Logger::root(drain, slog_o!("Hostname" => hostname, "Type" => "autopush_rs:log", "EnvVersion" => "2.0", "Logger" => format!("AutopushRust-{}", env!("CARGO_PKG_VERSION")))); + let _scope_guard = slog_scope::set_global_logger(logger); + slog_stdlog::init().ok(); + LogGuards { + _scope_guard: _scope_guard, + } } }