options: add set_info_log_level to control log verbosity (#553)

master
Thomas Kintscher 3 years ago committed by GitHub
parent eb2d302682
commit 0976f770fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 31
      src/db_options.rs
  2. 4
      src/lib.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 { impl Options {
/// By default, RocksDB uses only one background thread for flush and /// By default, RocksDB uses only one background thread for flush and
/// compaction. Calling this function will set it up such that total of /// 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 /// Allows OS to incrementally sync files to disk while they are being
/// written, asynchronously, in the background. This operation can be used /// 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 /// to smooth out write I/Os over time. Users shouldn't rely on it for

@ -110,8 +110,8 @@ pub use crate::{
BlockBasedIndexType, BlockBasedOptions, BottommostLevelCompaction, Cache, CompactOptions, BlockBasedIndexType, BlockBasedOptions, BottommostLevelCompaction, Cache, CompactOptions,
CuckooTableOptions, DBCompactionStyle, DBCompressionType, DBPath, DBRecoveryMode, CuckooTableOptions, DBCompactionStyle, DBCompressionType, DBPath, DBRecoveryMode,
DataBlockIndexType, Env, FifoCompactOptions, FlushOptions, IngestExternalFileOptions, DataBlockIndexType, Env, FifoCompactOptions, FlushOptions, IngestExternalFileOptions,
MemtableFactory, Options, PlainTableFactoryOptions, ReadOptions, UniversalCompactOptions, LogLevel, MemtableFactory, Options, PlainTableFactoryOptions, ReadOptions,
UniversalCompactionStopStyle, WriteOptions, UniversalCompactOptions, UniversalCompactionStopStyle, WriteOptions,
}, },
db_pinnable_slice::DBPinnableSlice, db_pinnable_slice::DBPinnableSlice,
merge_operator::MergeOperands, merge_operator::MergeOperands,

Loading…
Cancel
Save