diff --git a/Cargo.lock b/Cargo.lock index f6cc0ba..603e3f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -384,6 +384,16 @@ 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" @@ -1493,6 +1503,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" dependencies = [ "cfg-if", + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1509,6 +1520,23 @@ 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" @@ -1563,7 +1591,7 @@ dependencies = [ [[package]] name = "trader" -version = "1.0.1" +version = "1.0.2" dependencies = [ "alpaca", "anyhow", @@ -1577,6 +1605,7 @@ dependencies = [ "serde_json", "tokio", "tracing", + "tracing-bunyan-formatter", "tracing-log", "tracing-subscriber", "uuid", diff --git a/Cargo.toml b/Cargo.toml index 0782e8d..d22dea2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trader" -version = "1.0.1" +version = "1.0.2" authors = ["RollenRegistratorBot "] edition = "2018" @@ -18,6 +18,7 @@ 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 0254afd..1ae83fb 100644 --- a/src/telemetry.rs +++ b/src/telemetry.rs @@ -1,11 +1,13 @@ -use tracing::{subscriber::set_global_default, Subscriber}; +use tracing::subscriber::{set_global_default, Subscriber}; +use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer}; use tracing_log::LogTracer; -use tracing_subscriber::{EnvFilter, FmtSubscriber}; +use tracing_subscriber::{layer::SubscriberExt, Registry}; pub fn get_subscriber() -> impl Subscriber + Send + Sync { - FmtSubscriber::builder() - .with_env_filter(EnvFilter::from_default_env()) - .finish() + let formatting_layer = BunyanFormattingLayer::new("polygon-data-relay".into(), std::io::stdout); + Registry::default() + .with(JsonStorageLayer) + .with(formatting_layer) } pub fn init_subscriber(subscriber: impl Subscriber + Send + Sync) {