Skip to content

Commit

Permalink
Merge pull request #297 from hannobraun/tracing
Browse files Browse the repository at this point in the history
Improve logging
  • Loading branch information
hannobraun authored Mar 7, 2022
2 parents b044e9d + 1414ec6 commit 9496456
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
37 changes: 37 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ path = "fj"

[dependencies.tracing-subscriber]
version = "0.3.9"
features = ["fmt"]
features = ["env-filter", "fmt"]
15 changes: 14 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use std::{collections::HashMap, sync::mpsc, time::Instant};
use futures::executor::block_on;
use notify::Watcher as _;
use tracing::trace;
use tracing_subscriber::fmt::format;
use tracing_subscriber::EnvFilter;
use winit::{
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
Expand All @@ -34,7 +36,18 @@ use crate::{
};

fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt::init();
// Respect `RUST_LOG`. If that's not defined or erroneous, log warnings and
// above.
//
// It would be better to fail, if `RUST_LOG` is erroneous, but I don't know
// how to distinguish between that and the "not defined" case.
tracing_subscriber::fmt()
.with_env_filter(
EnvFilter::try_from_default_env()
.unwrap_or_else(|_| EnvFilter::new("WARN")),
)
.event_format(format().pretty())
.init();

let args = Args::parse();
let model = Model::new(args.model);
Expand Down

0 comments on commit 9496456

Please sign in to comment.