diff options
author | Akshay <[email protected]> | 2020-08-23 16:56:02 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2020-08-23 16:56:02 +0100 |
commit | 311b48924d2e20deb8733a2b94a531f55a83e205 (patch) | |
tree | b77895990e09ae425e710dfaa37b6ac338306dae /src/db.rs | |
parent | e16743598ccdaae9709034a7215c35ccfe2a49fa (diff) |
add logging
Diffstat (limited to 'src/db.rs')
-rw-r--r-- | src/db.rs | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1,11 +1,14 @@ | |||
1 | use anyhow::Result; | 1 | use anyhow::Result; |
2 | use log::{debug, info}; | ||
2 | use rusqlite::{Connection, OpenFlags, NO_PARAMS}; | 3 | use rusqlite::{Connection, OpenFlags, NO_PARAMS}; |
3 | 4 | ||
5 | use std::fmt; | ||
4 | use std::path::Path; | 6 | use std::path::Path; |
5 | 7 | ||
6 | pub fn init_db<P: AsRef<Path>>(p: P) -> Result<Connection> { | 8 | pub fn init_db<P: AsRef<Path> + fmt::Display>(p: P) -> Result<Connection> { |
9 | debug!("Looking for database at `{}`", p); | ||
7 | let conn = Connection::open_with_flags( | 10 | let conn = Connection::open_with_flags( |
8 | p, | 11 | &p, |
9 | OpenFlags::SQLITE_OPEN_CREATE | OpenFlags::SQLITE_OPEN_READ_WRITE, | 12 | OpenFlags::SQLITE_OPEN_CREATE | OpenFlags::SQLITE_OPEN_READ_WRITE, |
10 | )?; | 13 | )?; |
11 | conn.execute( | 14 | conn.execute( |
@@ -15,5 +18,6 @@ pub fn init_db<P: AsRef<Path>>(p: P) -> Result<Connection> { | |||
15 | )", | 18 | )", |
16 | NO_PARAMS, | 19 | NO_PARAMS, |
17 | )?; | 20 | )?; |
21 | info!("SQLite3 database `{}` initialized", &p); | ||
18 | return Ok(conn); | 22 | return Ok(conn); |
19 | } | 23 | } |