refactor: use tracing's formatting machinery

This commit is contained in:
Harsh Shandilya 2022-05-19 06:42:37 +05:30
parent 487e8eadbb
commit 8003246afd
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80

View file

@ -22,7 +22,7 @@ impl<'a> ClipboardHandler for Handler<'a> {
.find(|subst| subst.matcher.check_match(&contents))
{
if subst.name.is_empty().not() {
debug!("{}: matched on {}...", &subst.name, truncate(&contents, 40));
debug!(?subst.name, ?contents);
}
let result = subst.action.apply_action(&contents);
if let Err(e) = self.ctx.set_contents(result) {
@ -39,13 +39,6 @@ impl<'a> ClipboardHandler for Handler<'a> {
}
}
fn truncate(s: &str, max_chars: usize) -> &str {
match s.char_indices().nth(max_chars) {
None => s,
Some((idx, _)) => &s[..idx],
}
}
pub fn monitor(config: Replacements<'_>) {
let ctx = ClipboardContext::new().expect("Failed to acquire clipboard");
let handler = Handler { ctx, config };