Skip to content

Commit

Permalink
Merge pull request #26 from Overmuse/SR/json_log_format
Browse files Browse the repository at this point in the history
format logs as json
  • Loading branch information
SebRollen authored Jun 16, 2021
2 parents 51c53ab + ef37fc3 commit d4e18cb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
31 changes: 30 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "trader"
version = "1.0.1"
version = "1.0.2"
authors = ["RollenRegistratorBot <[email protected]>"]
edition = "2018"

Expand All @@ -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"
Expand Down
12 changes: 7 additions & 5 deletions src/telemetry.rs
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down

0 comments on commit d4e18cb

Please sign in to comment.