mirror of
https://github.com/msfjarvis/gitice
synced 2025-08-14 22:07:00 +05:30
feat: set up tracing
This commit is contained in:
parent
6c02e4edfd
commit
b37ede3442
4 changed files with 157 additions and 18 deletions
16
src/logging.rs
Normal file
16
src/logging.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
use tracing::dispatcher::SetGlobalDefaultError;
|
||||
use tracing::subscriber::set_global_default;
|
||||
use tracing::Level;
|
||||
use tracing_subscriber::{filter::Targets, fmt, layer::SubscriberExt, registry, Layer};
|
||||
|
||||
fn configure_tracing(filter: Targets) -> Result<(), SetGlobalDefaultError> {
|
||||
let registry = registry();
|
||||
let stdout_log = fmt::layer().compact();
|
||||
let subscriber = registry.with(stdout_log.with_filter(filter));
|
||||
set_global_default(subscriber)
|
||||
}
|
||||
|
||||
pub(crate) fn init() -> Result<(), SetGlobalDefaultError> {
|
||||
let tracing_filter = Targets::new().with_target("gitice", Level::TRACE);
|
||||
configure_tracing(tracing_filter)
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
pub(crate) mod cli;
|
||||
pub(crate) mod git;
|
||||
pub(crate) mod logging;
|
||||
pub(crate) mod model;
|
||||
|
||||
use clap::Parser;
|
||||
|
@ -8,6 +9,7 @@ use git::freeze_repos;
|
|||
use git::thaw_repos;
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
logging::init()?;
|
||||
let opts = Opts::parse();
|
||||
|
||||
match opts.subcommand {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue