Skip to content

Commit

Permalink
#290 Add option to disable SQLx logging
Browse files Browse the repository at this point in the history
  • Loading branch information
tyt2y3 committed Nov 4, 2021
1 parent e2d4ccf commit 6a0db92
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct ConnectOptions {
/// Maximum idle time for a particular connection to prevent
/// network resource exhaustion
pub(crate) idle_timeout: Option<Duration>,
/// Enables or disables logging
/// Enable SQLx statement logging
pub(crate) sqlx_logging: bool,
}

Expand Down Expand Up @@ -128,6 +128,11 @@ impl ConnectOptions {
opt
}

/// Get the database URL of the pool
pub fn get_url(&self) -> &str {
&self.url
}

/// Set the maximum number of connections of the pool
pub fn max_connections(&mut self, value: u32) -> &mut Self {
self.max_connections = Some(value);
Expand Down Expand Up @@ -171,4 +176,15 @@ impl ConnectOptions {
pub fn get_idle_timeout(&self) -> Option<Duration> {
self.idle_timeout
}

/// Enable SQLx statement logging (default true)
pub fn sqlx_logging(&mut self, value: bool) -> &mut Self {
self.sqlx_logging = value;
self
}

/// Get whether SQLx statement logging is enabled
pub fn get_sqlx_logging(&self) -> bool {
self.sqlx_logging
}
}

0 comments on commit 6a0db92

Please sign in to comment.