From 0976f770fa4b9805c0a0481737c38e013713d57b Mon Sep 17 00:00:00 2001 From: Thomas Kintscher Date: Thu, 18 Nov 2021 07:52:51 +0100 Subject: [PATCH] options: add set_info_log_level to control log verbosity (#553) --- src/db_options.rs | 31 +++++++++++++++++++++++++++++++ src/lib.rs | 4 ++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/db_options.rs b/src/db_options.rs index 2886497..bdb92a0 100644 --- a/src/db_options.rs +++ b/src/db_options.rs @@ -789,6 +789,18 @@ impl Default for CuckooTableOptions { } } +// Verbosity of the LOG. +#[derive(Debug, Copy, Clone, PartialEq)] +#[repr(i32)] +pub enum LogLevel { + Debug = 0, + Info, + Warn, + Error, + Fatal, + Header, +} + impl Options { /// By default, RocksDB uses only one background thread for flush and /// compaction. Calling this function will set it up such that total of @@ -1380,6 +1392,25 @@ impl Options { } } + /// Specifies the log level. + /// Consider the `LogLevel` enum for a list of possible levels. + /// + /// Default: Info + /// + /// # Examples + /// + /// ``` + /// use rocksdb::{Options, LogLevel}; + /// + /// let mut opts = Options::default(); + /// opts.set_log_level(LogLevel::Warn); + /// ``` + pub fn set_log_level(&mut self, level: LogLevel) { + unsafe { + ffi::rocksdb_options_set_info_log_level(self.inner, level as c_int); + } + } + /// Allows OS to incrementally sync files to disk while they are being /// written, asynchronously, in the background. This operation can be used /// to smooth out write I/Os over time. Users shouldn't rely on it for diff --git a/src/lib.rs b/src/lib.rs index 71fee88..298fa08 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -110,8 +110,8 @@ pub use crate::{ BlockBasedIndexType, BlockBasedOptions, BottommostLevelCompaction, Cache, CompactOptions, CuckooTableOptions, DBCompactionStyle, DBCompressionType, DBPath, DBRecoveryMode, DataBlockIndexType, Env, FifoCompactOptions, FlushOptions, IngestExternalFileOptions, - MemtableFactory, Options, PlainTableFactoryOptions, ReadOptions, UniversalCompactOptions, - UniversalCompactionStopStyle, WriteOptions, + LogLevel, MemtableFactory, Options, PlainTableFactoryOptions, ReadOptions, + UniversalCompactOptions, UniversalCompactionStopStyle, WriteOptions, }, db_pinnable_slice::DBPinnableSlice, merge_operator::MergeOperands,