mirror of
https://github.com/msfjarvis/clipboard-substitutor
synced 2025-08-14 21:17:01 +05:30
refactor: switch logging to tracing
Adds in slightly more dependencies than I'd like but at least it works
This commit is contained in:
parent
b938a6001b
commit
ea3ad1889c
3 changed files with 137 additions and 3 deletions
12
src/main.rs
12
src/main.rs
|
@ -9,7 +9,8 @@ use std::path::PathBuf;
|
|||
use anyhow::{anyhow, Result};
|
||||
use clipboard::{ClipboardContext, ClipboardProvider};
|
||||
use dirs::config_dir;
|
||||
use log::{debug, error};
|
||||
use tracing::{debug, error, Level};
|
||||
use tracing_subscriber::FmtSubscriber;
|
||||
|
||||
use crate::config::{Act, Match, Replacements};
|
||||
|
||||
|
@ -19,6 +20,7 @@ fn main() -> Result<()> {
|
|||
if check_for_version_arg() {
|
||||
return Ok(());
|
||||
}
|
||||
configure_tracing();
|
||||
let config_path = get_config_path()?;
|
||||
let config_str = std::fs::read_to_string(config_path.as_path()).unwrap_or_default();
|
||||
let config: Replacements<'_> = toml::from_str(&config_str)?;
|
||||
|
@ -44,6 +46,14 @@ fn print_version() {
|
|||
);
|
||||
}
|
||||
|
||||
fn configure_tracing() {
|
||||
let subscriber = FmtSubscriber::builder()
|
||||
.with_max_level(Level::TRACE)
|
||||
.finish();
|
||||
|
||||
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
|
||||
}
|
||||
|
||||
fn get_config_path() -> Result<PathBuf> {
|
||||
let mut config_path = config_dir().ok_or_else(|| anyhow!("Failed to get config dir"))?;
|
||||
config_path.push("substitutor");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue