diff --git a/services/appflowy-history/src/config.rs b/services/appflowy-history/src/config.rs index b3cda59b..3c8fea9e 100644 --- a/services/appflowy-history/src/config.rs +++ b/services/appflowy-history/src/config.rs @@ -3,7 +3,7 @@ use collab_stream::client::CONTROL_STREAM_KEY; use infra::env_util::get_env_var; use serde::Deserialize; use sqlx::postgres::{PgConnectOptions, PgSslMode}; -use std::str::FromStr; +use std::{fmt::Display, str::FromStr}; #[derive(Debug, Clone)] pub struct Config { @@ -64,6 +64,17 @@ impl DatabaseSetting { } } +impl Display for DatabaseSetting { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let masked_pg_conn_opts = self.pg_conn_opts.clone().password("********"); + write!( + f, + "DatabaseSetting {{ pg_conn_opts: {:?}, require_ssl: {}, max_connections: {} }}", + masked_pg_conn_opts, self.require_ssl, self.max_connections + ) + } +} + #[derive(Debug, Clone)] pub struct StreamSetting { /// The key of the stream that contains control event, [CollabControlEvent]. diff --git a/services/appflowy-worker/src/config.rs b/services/appflowy-worker/src/config.rs index 1288a635..a5bcea03 100644 --- a/services/appflowy-worker/src/config.rs +++ b/services/appflowy-worker/src/config.rs @@ -4,7 +4,7 @@ use mailer::config::MailerSetting; use secrecy::Secret; use serde::Deserialize; use sqlx::postgres::{PgConnectOptions, PgSslMode}; -use std::str::FromStr; +use std::{fmt::Display, str::FromStr}; #[derive(Debug, Clone)] pub struct Config { @@ -79,6 +79,17 @@ impl DatabaseSetting { } } +impl Display for DatabaseSetting { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let masked_pg_conn_opts = self.pg_conn_opts.clone().password("********"); + write!( + f, + "DatabaseSetting {{ pg_conn_opts: {:?}, require_ssl: {}, max_connections: {} }}", + masked_pg_conn_opts, self.require_ssl, self.max_connections + ) + } +} + #[derive(Debug, Clone)] pub struct StreamSetting { /// The key of the stream that contains control event, [CollabControlEvent]. diff --git a/src/config/config.rs b/src/config/config.rs index 575370eb..47c6de7d 100644 --- a/src/config/config.rs +++ b/src/config/config.rs @@ -115,10 +115,11 @@ pub struct DatabaseSetting { impl Display for DatabaseSetting { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let masked_pg_conn_opts = self.pg_conn_opts.clone().password("********"); write!( f, "DatabaseSetting {{ pg_conn_opts: {:?}, require_ssl: {}, max_connections: {} }}", - self.pg_conn_opts, self.require_ssl, self.max_connections + masked_pg_conn_opts, self.require_ssl, self.max_connections ) } }