Skip to content

Commit

Permalink
Replaces env_logger with Tokio non-blocking tracing. (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
silathdiir authored Jun 13, 2021
1 parent 247449b commit 258333a
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 48 deletions.
136 changes: 93 additions & 43 deletions 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
Expand Up @@ -13,7 +13,6 @@ chrono = { version = "0.4.19", features = [ "serde" ] }
config_rs = { package = "config", version = "0.10.1" }
crossbeam-channel = "0.5.0"
dotenv = "0.15.0"
env_logger = "0.8.3"
futures = "0.3.13"
futures-channel = "0.3.13"
futures-core = { version = "0.3.13", default-features = false }
Expand All @@ -38,6 +37,9 @@ thiserror = "1.0.24"
thread-id = "3.3.0"
tokio = { version = "1.6.0", features = [ "full" ] }
tonic = "0.4.0"
tracing = "0.1"
tracing-appender = "0.1"
tracing-subscriber = "0.2"
ttl_cache = "0.5.1"

[build-dependencies]
Expand Down
8 changes: 7 additions & 1 deletion src/bin/matchengine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ use sqlx::Connection;

fn main() {
dotenv::dotenv().ok();
env_logger::init();

let (non_blocking, _guard) = tracing_appender::non_blocking(std::io::stdout());
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.with_writer(non_blocking)
.init();

let rt: tokio::runtime::Runtime = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
Expand Down
7 changes: 6 additions & 1 deletion src/bin/persistor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ use message::persist::{self, TopicConfig, MIGRATOR};

fn main() {
dotenv::dotenv().ok();
env_logger::init();

let (non_blocking, _guard) = tracing_appender::non_blocking(std::io::stdout());
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.with_writer(non_blocking)
.init();

let mut conf = config_rs::Config::new();
let config_file = dotenv::var("CONFIG_FILE").unwrap();
Expand Down
8 changes: 7 additions & 1 deletion src/bin/restapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ async fn ping(_req: HttpRequest, _data: web::Data<AppState>) -> impl Responder {
#[actix_web::main]
async fn main() -> std::io::Result<()> {
dotenv::dotenv().ok();
env_logger::init();

let (non_blocking, _guard) = tracing_appender::non_blocking(std::io::stdout());
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.with_writer(non_blocking)
.init();

let mut conf = config_rs::Config::new();
let config_file = dotenv::var("CONFIG_FILE").unwrap();
conf.merge(config_rs::File::with_name(&config_file)).unwrap();
Expand Down
7 changes: 6 additions & 1 deletion src/bin/test_unifymessenger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ impl SimpleMessageHandler for &MessageWriter {

fn main() {
dotenv::dotenv().ok();
env_logger::init();

let (non_blocking, _guard) = tracing_appender::non_blocking(std::io::stdout());
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.with_writer(non_blocking)
.init();

let mut conf = config_rs::Config::new();
let config_file = dotenv::var("CONFIG_FILE").unwrap();
Expand Down

0 comments on commit 258333a

Please sign in to comment.