Skip to content

Commit

Permalink
Merge pull request #5 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 ab76d5c + e86b12f commit 7a6e9c8
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
32 changes: 31 additions & 1 deletion Cargo.lock

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

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

Expand All @@ -19,7 +19,9 @@ serde = { version = "1.0.125", features = ["derive"] }
stream-processor = { git = "ssh://[email protected]/Overmuse/stream-processor", tag = "v0.2.1" }
tokio = { version = "1.4.0", features = ["macros", "rt-multi-thread"] }
tracing = "0.1.25"
tracing-log = "0.1.2"
tracing-subscriber = "0.2.17"
tracing-bunyan-formatter = { version = "0.2.4", default-features = false }
uuid = "0.8.2"

[dev-dependencies]
Expand Down
16 changes: 10 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
use anyhow::Result;
use tca::{run, Settings};
use tracing::subscriber::set_global_default;
use tracing_subscriber::{EnvFilter, FmtSubscriber};
use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer};
use tracing_log::LogTracer;
use tracing_subscriber::{layer::SubscriberExt, Registry};

#[tokio::main]
async fn main() -> Result<()> {
dotenv::dotenv().ok();
let subscriber = FmtSubscriber::builder()
.with_env_filter(EnvFilter::from_default_env())
.finish();
set_global_default(subscriber)?;
let _ = dotenv::dotenv();
let formatting_layer = BunyanFormattingLayer::new("tca".into(), std::io::stdout);
let subscriber = Registry::default()
.with(JsonStorageLayer)
.with(formatting_layer);
set_global_default(subscriber).expect("Failed to set subscriber");
LogTracer::init().expect("Failed to set logger");
let settings = Settings::new()?;
run(settings).await
}

0 comments on commit 7a6e9c8

Please sign in to comment.