Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "feat: allow log level customization (#1371)" #1465

Merged
merged 1 commit into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions sqlx-core/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::database::{Database, HasStatementCache};
use crate::error::Error;
use crate::transaction::Transaction;
use futures_core::future::BoxFuture;
pub use log::LevelFilter;
use log::LevelFilter;
use std::fmt::Debug;
use std::str::FromStr;
use std::time::Duration;
Expand Down Expand Up @@ -126,27 +126,27 @@ pub trait Connection: Send {
}

#[derive(Clone, Debug)]
pub struct LogSettings {
pub statements_level: LevelFilter,
pub slow_statements_level: LevelFilter,
pub slow_statements_duration: Duration,
pub(crate) struct LogSettings {
pub(crate) statements_level: LevelFilter,
pub(crate) slow_statements_level: LevelFilter,
pub(crate) slow_statements_duration: Duration,
}

impl Default for LogSettings {
fn default() -> Self {
LogSettings {
statements_level: LevelFilter::Debug,
statements_level: LevelFilter::Info,
slow_statements_level: LevelFilter::Warn,
slow_statements_duration: Duration::from_secs(1),
}
}
}

impl LogSettings {
pub fn log_statements(&mut self, level: LevelFilter) {
pub(crate) fn log_statements(&mut self, level: LevelFilter) {
self.statements_level = level;
}
pub fn log_slow_statements(&mut self, level: LevelFilter, duration: Duration) {
pub(crate) fn log_slow_statements(&mut self, level: LevelFilter, duration: Duration) {
self.slow_statements_level = level;
self.slow_statements_duration = duration;
}
Expand Down
17 changes: 0 additions & 17 deletions sqlx-core/src/mysql/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,21 +212,4 @@ impl MySqlConnectOptions {
self.collation = Some(collation.to_owned());
self
}

/// Sets the log settings.
///
/// # Example
///
/// ```rust
/// # use sqlx_core::mysql::MySqlConnectOptions;
/// let options = MySqlConnectOptions::new()
/// .log_settings(sqlx_core::connection::LogSettings {
/// statements_level: sqlx_core::connection::LevelFilter::Info,
/// ..Default::default()
/// });
/// ```
pub fn log_settings(mut self, log_settings: LogSettings) -> Self {
self.log_settings = log_settings;
self
}
}
17 changes: 0 additions & 17 deletions sqlx-core/src/postgres/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,23 +319,6 @@ impl PgConnectOptions {
self
}

/// Sets the log settings.
///
/// # Example
///
/// ```rust
/// # use sqlx_core::postgres::PgConnectOptions;
/// let options = PgConnectOptions::new()
/// .log_settings(sqlx_core::connection::LogSettings {
/// statements_level: sqlx_core::connection::LevelFilter::Info,
/// ..Default::default()
/// });
/// ```
pub fn log_settings(mut self, log_settings: LogSettings) -> Self {
self.log_settings = log_settings;
self
}

/// We try using a socket if hostname starts with `/` or if socket parameter
/// is specified.
pub(crate) fn fetch_socket(&self) -> Option<String> {
Expand Down
17 changes: 0 additions & 17 deletions sqlx-core/src/sqlite/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,4 @@ impl SqliteConnectOptions {
self.immutable = immutable;
self
}

/// Sets the log settings.
///
/// # Example
///
/// ```rust
/// # use sqlx_core::sqlite::SqliteConnectOptions;
/// let options = SqliteConnectOptions::new()
/// .log_settings(sqlx_core::connection::LogSettings {
/// statements_level: sqlx_core::connection::LevelFilter::Info,
/// ..Default::default()
/// });
/// ```
pub fn log_settings(mut self, log_settings: LogSettings) -> Self {
self.log_settings = log_settings;
self
}
}