Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up logging in model handler #2013

Merged
merged 2 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 100 additions & 3 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions crates/fj/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ fj-math.workspace = true
fj-viewer.workspace = true
fj-window.workspace = true
thiserror = "1.0.48"
tracing = "0.1.37"

[dependencies.clap]
version = "4.4.2"
features = ["derive"]

[dependencies.tracing-subscriber]
version = "0.3.17"
features = ["env-filter"]
10 changes: 10 additions & 0 deletions crates/fj/src/handle_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use fj_core::{
};
use fj_interop::model::Model;
use fj_math::{Aabb, Point, Scalar};
use tracing_subscriber::prelude::*;

use crate::Args;

Expand All @@ -30,6 +31,11 @@ where
for<'r> (&'r M, Tolerance): Triangulate,
M: BoundingVolume<3>,
{
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
.with(tracing_subscriber::EnvFilter::from_default_env())
.init();

let args = Args::parse();

if args.ignore_validation {
Expand Down Expand Up @@ -82,6 +88,10 @@ pub type Result = std::result::Result<(), Error>;
/// Error returned by [`handle_model`]
#[derive(thiserror::Error)]
pub enum Error {
/// Failed to set up logger
#[error("Failed to set up logger")]
Tracing(#[from] tracing::subscriber::SetGlobalDefaultError),

/// Error displaying model
#[error("Error displaying model")]
Display(#[from] crate::window::Error),
Expand Down