From 2b54c00f04ab029e14accb742ea049c8e484e29c Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 13 Apr 2024 17:58:13 -0700 Subject: [PATCH] add config option to disable rocksdb LOG file Signed-off-by: Jason Volk --- src/config/mod.rs | 10 +++++++--- src/database/rocksdb/opts.rs | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index 047c5ca5..0a9e4d94 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -190,6 +190,8 @@ pub struct Config { #[serde(default = "default_rocksdb_log_level")] pub rocksdb_log_level: String, + #[serde(default)] + pub rocksdb_log_stderr: bool, #[serde(default = "default_rocksdb_max_log_file_size")] pub rocksdb_max_log_file_size: usize, #[serde(default = "default_rocksdb_log_time_to_roll")] @@ -634,14 +636,16 @@ impl fmt::Display for Config { #[cfg(feature = "brotli_compression")] ("Brotli HTTP Compression", &self.brotli_compression.to_string()), #[cfg(feature = "rocksdb")] - ("RocksDB database log level", &self.rocksdb_log_level), + ("RocksDB database LOG level", &self.rocksdb_log_level), #[cfg(feature = "rocksdb")] - ("RocksDB database log time-to-roll", &self.rocksdb_log_time_to_roll.to_string()), + ("RocksDB database LOG to stderr", &self.rocksdb_log_stderr.to_string()), + #[cfg(feature = "rocksdb")] + ("RocksDB database LOG time-to-roll", &self.rocksdb_log_time_to_roll.to_string()), #[cfg(feature = "rocksdb")] ("RocksDB Max LOG Files", &self.rocksdb_max_log_files.to_string()), #[cfg(feature = "rocksdb")] ( - "RocksDB database max log file size", + "RocksDB database max LOG file size", &self.rocksdb_max_log_file_size.to_string(), ), #[cfg(feature = "rocksdb")] diff --git a/src/database/rocksdb/opts.rs b/src/database/rocksdb/opts.rs index 67063b23..68b30b4d 100644 --- a/src/database/rocksdb/opts.rs +++ b/src/database/rocksdb/opts.rs @@ -161,6 +161,10 @@ fn set_logging_defaults(opts: &mut Options, config: &Config) { opts.set_log_file_time_to_roll(config.rocksdb_log_time_to_roll); opts.set_keep_log_file_num(config.rocksdb_max_log_files); opts.set_stats_dump_period_sec(0); + + if config.rocksdb_log_stderr { + opts.set_stderr_logger(rocksdb_log_level, "rocksdb"); + } } fn set_compression_defaults(opts: &mut Options, config: &Config) {