From fc5613f801652e7dda003d1be84b96be2cf3d1a7 Mon Sep 17 00:00:00 2001 From: Sebastian Rollen Date: Thu, 17 Jun 2021 23:02:13 -0400 Subject: [PATCH] better logging --- Cargo.lock | 32 +------------------------------- Cargo.toml | 4 +--- src/telemetry.rs | 13 +++++-------- 3 files changed, 7 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 603e3f7..18af65f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -384,16 +384,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "gethostname" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e692e296bfac1d2533ef168d0b60ff5897b8b70a4009276834014dd8924cc028" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "getrandom" version = "0.1.16" @@ -1503,7 +1493,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" dependencies = [ "cfg-if", - "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1520,23 +1509,6 @@ dependencies = [ "syn", ] -[[package]] -name = "tracing-bunyan-formatter" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dce1eae70720bd6bb3944f7cf501761aeae658bd1f9293aa373c71a195064910" -dependencies = [ - "chrono", - "gethostname", - "log", - "serde 1.0.125", - "serde_json", - "tracing", - "tracing-core", - "tracing-log", - "tracing-subscriber", -] - [[package]] name = "tracing-core" version = "0.1.17" @@ -1591,7 +1563,7 @@ dependencies = [ [[package]] name = "trader" -version = "1.0.2" +version = "1.0.3" dependencies = [ "alpaca", "anyhow", @@ -1605,8 +1577,6 @@ dependencies = [ "serde_json", "tokio", "tracing", - "tracing-bunyan-formatter", - "tracing-log", "tracing-subscriber", "uuid", ] diff --git a/Cargo.toml b/Cargo.toml index d22dea2..8b7b32c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trader" -version = "1.0.2" +version = "1.0.3" authors = ["RollenRegistratorBot "] edition = "2018" @@ -18,8 +18,6 @@ serde = "1.0.116" serde_json = "1.0.57" tokio = { version = "1.2", features = ["macros", "rt-multi-thread"] } tracing = "0.1" -tracing-bunyan-formatter = { version = "0.2.4", default-features = false } -tracing-log = "0.1" tracing-subscriber = "0.2" uuid = "0.8.1" diff --git a/src/telemetry.rs b/src/telemetry.rs index 1ae83fb..2d17aa4 100644 --- a/src/telemetry.rs +++ b/src/telemetry.rs @@ -1,16 +1,13 @@ use tracing::subscriber::{set_global_default, Subscriber}; -use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer}; -use tracing_log::LogTracer; -use tracing_subscriber::{layer::SubscriberExt, Registry}; +use tracing_subscriber::EnvFilter; pub fn get_subscriber() -> impl Subscriber + Send + Sync { - let formatting_layer = BunyanFormattingLayer::new("polygon-data-relay".into(), std::io::stdout); - Registry::default() - .with(JsonStorageLayer) - .with(formatting_layer) + tracing_subscriber::fmt() + .json() + .with_env_filter(EnvFilter::from_default_env()) + .finish() } pub fn init_subscriber(subscriber: impl Subscriber + Send + Sync) { - LogTracer::init().expect("Failed to set logger"); set_global_default(subscriber).expect("Failed to set subscriber"); }