mirror of
https://github.com/NotAShelf/stash.git
synced 2026-04-13 14:33:47 +00:00
treewide: improve logging; get rid of unwrap()s
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6a6a696442ff25c3f65bb2d5f68e0d78a569fd76
This commit is contained in:
parent
b0820a1940
commit
254c288111
11 changed files with 324 additions and 69 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use crate::db::{ClipboardDb, SledClipboardDb};
|
||||
|
||||
use std::io::{Read, Write};
|
||||
|
||||
pub trait DecodeCommand {
|
||||
|
|
@ -8,5 +9,6 @@ pub trait DecodeCommand {
|
|||
impl DecodeCommand for SledClipboardDb {
|
||||
fn decode(&self, in_: impl Read, out: impl Write, input: Option<String>) {
|
||||
self.decode_entry(in_, out, input);
|
||||
log::info!("Entry decoded");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::db::{ClipboardDb, SledClipboardDb};
|
||||
|
||||
use std::io::Read;
|
||||
|
||||
pub trait DeleteCommand {
|
||||
|
|
@ -8,5 +9,6 @@ pub trait DeleteCommand {
|
|||
impl DeleteCommand for SledClipboardDb {
|
||||
fn delete(&self, input: impl Read) {
|
||||
self.delete_entries(input);
|
||||
log::info!("Entries deleted");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,5 +8,6 @@ pub trait ListCommand {
|
|||
impl ListCommand for SledClipboardDb {
|
||||
fn list(&self, out: impl Write, preview_width: u32) {
|
||||
self.list_entries(out, preview_width);
|
||||
log::info!("Entries listed");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,5 +7,6 @@ pub trait QueryCommand {
|
|||
impl QueryCommand for SledClipboardDb {
|
||||
fn query_delete(&self, query: &str) {
|
||||
<SledClipboardDb as ClipboardDb>::delete_query(self, query);
|
||||
log::info!("Entries matching query '{}' deleted", query);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::db::{ClipboardDb, SledClipboardDb};
|
||||
|
||||
use std::io::Read;
|
||||
|
||||
pub trait StoreCommand {
|
||||
|
|
@ -19,13 +20,12 @@ impl StoreCommand for SledClipboardDb {
|
|||
max_items: u64,
|
||||
state: Option<String>,
|
||||
) {
|
||||
match state.as_deref() {
|
||||
Some("sensitive") | Some("clear") => {
|
||||
self.delete_last();
|
||||
}
|
||||
_ => {
|
||||
self.store_entry(input, max_dedupe_search, max_items);
|
||||
}
|
||||
if let Some("sensitive" | "clear") = state.as_deref() {
|
||||
self.delete_last();
|
||||
log::info!("Entry deleted");
|
||||
} else {
|
||||
self.store_entry(input, max_dedupe_search, max_items);
|
||||
log::info!("Entry stored");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,5 +7,6 @@ pub trait WipeCommand {
|
|||
impl WipeCommand for SledClipboardDb {
|
||||
fn wipe(&self) {
|
||||
self.wipe_db();
|
||||
log::info!("Database wiped");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue