summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2018-02-06 15:27:39 +0100
committerJustus Winter <justus@sequoia-pgp.org>2018-02-06 15:27:39 +0100
commita63fa8574b8fafd7c15c9f0045334cf5fdb0354a (patch)
tree87ca535a42cb9ce7b77cb9c4bf10a80038aeaf97
parent7ab5cde6f316f5d614cd6d4b577db473bd523378 (diff)
store: Improve log messages.
- Provide meaningful slugs. - Use key ids instead of fingerprints.
-rw-r--r--store/src/backend/mod.rs41
1 files changed, 36 insertions, 5 deletions
diff --git a/store/src/backend/mod.rs b/store/src/backend/mod.rs
index b4547da4..bc5a04b0 100644
--- a/store/src/backend/mod.rs
+++ b/store/src/backend/mod.rs
@@ -201,6 +201,17 @@ impl Query for StoreServer {
fn connection(&self) -> Rc<Connection> {
self.c.clone()
}
+
+ fn slug(&self) -> String {
+ self.c.query_row(
+ "SELECT domain, name FROM stores WHERE id = ?1",
+ &[&self.id], |row| -> String {
+ format!("{}:{}", row.get::<_, String>(0), row.get::<_, String>(1))
+ })
+ .unwrap_or(
+ format!("{}::{}", Self::table_name(), self.id().0)
+ )
+ }
}
impl StoreServer {
@@ -265,7 +276,7 @@ impl node::store::Server for StoreServer {
&self.c,
log::Refers::to().store(self.id).binding(binding_id).key(key_id),
&self.slug(),
- &format!("New binding {} -> {}", label, fp)));
+ &format!("New binding {} -> {}", label, fp.to_keyid())));
}
@@ -403,6 +414,17 @@ impl Query for BindingServer {
fn connection(&self) -> Rc<Connection> {
self.c.clone()
}
+
+ fn slug(&self) -> String {
+ self.c.query_row(
+ "SELECT label FROM bindings WHERE id = ?1",
+ &[&self.id], |row| -> String {
+ row.get(0)
+ })
+ .unwrap_or(
+ format!("{}::{}", Self::table_name(), self.id().0)
+ )
+ }
}
impl node::binding::Server for BindingServer {
@@ -793,6 +815,18 @@ impl Query for KeyServer {
fn connection(&self) -> Rc<Connection> {
self.c.clone()
}
+
+ fn slug(&self) -> String {
+ self.c.query_row(
+ "SELECT fingerprint FROM keys WHERE id = ?1",
+ &[&self.id], |row| -> String { row.get(0) })
+ .ok()
+ .and_then(|fp| Fingerprint::from_hex(&fp))
+ .map(|fp| fp.to_keyid().to_string())
+ .unwrap_or(
+ format!("{}::{}", Self::table_name(), self.id().0)
+ )
+ }
}
impl node::key::Server for KeyServer {
@@ -847,10 +881,7 @@ trait Query {
fn table_name() -> &'static str;
fn id(&self) -> ID;
fn connection(&self) -> Rc<Connection>;
-
- fn slug(&self) -> String {
- format!("{}::{}", Self::table_name(), self.id().0)
- }
+ fn slug(&self) -> String;
fn query(&mut self, column: &str) -> Result<i64> {
self.connection().query_row(