fix: tracing target has to be static
parent
363ddfc3fe
commit
ee8dc40577
|
@ -75,14 +75,14 @@ type DbPool = r2d2::Pool<ConnectionManager<SqliteConnection>>;
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct LoggingHandler {
|
||||
pub target: &'static str,
|
||||
pub name: &'static str,
|
||||
}
|
||||
|
||||
impl diesel::r2d2::HandleError<diesel::r2d2::Error> for LoggingHandler {
|
||||
fn handle_error(&self, error: diesel::r2d2::Error) {
|
||||
error!(target: self.target, "{}", error);
|
||||
error!(name = self.name, "Database error: {}", error);
|
||||
if is_debug() {
|
||||
panic!("This should not happen! {}", error);
|
||||
panic!("Database error! This should not happen! {}", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,9 +127,7 @@ impl UpEndDatabase {
|
|||
enable_foreign_keys: true,
|
||||
busy_timeout: Some(Duration::from_secs(30)),
|
||||
}))
|
||||
.error_handler(Box::new(LoggingHandler {
|
||||
target: "upend::db::main",
|
||||
}))
|
||||
.error_handler(Box::new(LoggingHandler { name: "main" }))
|
||||
.build(manager)?;
|
||||
trace!("Pool created.");
|
||||
|
||||
|
|
|
@ -122,9 +122,7 @@ impl FsStore {
|
|||
|
||||
let pool = r2d2::Pool::builder()
|
||||
.connection_customizer(Box::new(ConnectionOptions {}))
|
||||
.error_handler(Box::new(LoggingHandler {
|
||||
target: "upend::db::fs",
|
||||
}))
|
||||
.error_handler(Box::new(LoggingHandler { name: "fs_store" }))
|
||||
.build(manager)?;
|
||||
|
||||
let lock = Arc::new(RwLock::new(()));
|
||||
|
|
Loading…
Reference in New Issue