mirror of
https://github.com/msfjarvis/clipboard-substitutor
synced 2025-08-14 22:27:03 +05:30
feat(logging): add a journald feature to log to systemd
This commit is contained in:
parent
28fa08a67b
commit
139e833d04
3 changed files with 26 additions and 0 deletions
10
src/main.rs
10
src/main.rs
|
@ -10,6 +10,8 @@ use anyhow::{anyhow, Result};
|
|||
use clipboard::{ClipboardContext, ClipboardProvider};
|
||||
use dirs::config_dir;
|
||||
use tracing::{debug, error, Level};
|
||||
#[cfg(journald)]
|
||||
use tracing_journald::Subscriber;
|
||||
use tracing_subscriber::FmtSubscriber;
|
||||
|
||||
use crate::config::{Act, Match, Replacements};
|
||||
|
@ -47,6 +49,7 @@ fn print_version() {
|
|||
);
|
||||
}
|
||||
|
||||
#[cfg(not(journald))]
|
||||
fn configure_tracing() {
|
||||
let subscriber = FmtSubscriber::builder()
|
||||
.with_max_level(Level::TRACE)
|
||||
|
@ -56,6 +59,13 @@ fn configure_tracing() {
|
|||
.expect("setting default subscriber failed");
|
||||
}
|
||||
|
||||
#[cfg(journald)]
|
||||
fn configure_tracing() {
|
||||
let sub = Registry::default()
|
||||
.with(Subscriber::new().unwrap().with_field_prefix(None));
|
||||
tracing::collect::with_default(sub, f);
|
||||
}
|
||||
|
||||
fn get_config_path() -> Result<PathBuf> {
|
||||
let mut config_path =
|
||||
config_dir().ok_or_else(|| anyhow!("Failed to get config dir"))?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue