diff --git a/spdlog/src/lib.rs b/spdlog/src/lib.rs index 4c0089c4..486bc424 100644 --- a/spdlog/src/lib.rs +++ b/spdlog/src/lib.rs @@ -328,7 +328,7 @@ use std::{ use cfg_if::cfg_if; use error::EnvLevelError; -use sink::{Sink, StdStream, StdStreamSink}; +use sink::{Sink, StdStreamSink}; use sync::*; /// The statically resolved log level filter. @@ -388,13 +388,13 @@ static DEFAULT_LOGGER: OnceCell> = OnceCell::new(); fn default_logger_ref() -> &'static ArcSwap { DEFAULT_LOGGER.get_or_init(|| { let stdout = StdStreamSink::builder() - .std_stream(StdStream::Stdout) + .stdout() .level_filter(LevelFilter::MoreVerbose(Level::Warn)) .build() .unwrap(); let stderr = StdStreamSink::builder() - .std_stream(StdStream::Stderr) + .stderr() .level_filter(LevelFilter::MoreSevereEqual(Level::Warn)) .build() .unwrap(); diff --git a/spdlog/src/sink/std_stream_sink.rs b/spdlog/src/sink/std_stream_sink.rs index a03199d0..df3d66fb 100644 --- a/spdlog/src/sink/std_stream_sink.rs +++ b/spdlog/src/sink/std_stream_sink.rs @@ -217,6 +217,30 @@ pub struct StdStreamSinkBuilder { } impl StdStreamSinkBuilder { + /// Specifies the target standard stream as stdout. + /// + /// This is equivalent to `std_stream(StdStream::Stdout)`. + #[must_use] + pub fn stdout(self) -> StdStreamSinkBuilder { + StdStreamSinkBuilder { + common_builder_impl: self.common_builder_impl, + std_stream: StdStream::Stdout, + style_mode: self.style_mode, + } + } + + /// Specifies the target standard stream as stderr. + /// + /// This is equivalent to `std_stream(StdStream::Stderr)`. + #[must_use] + pub fn stderr(self) -> StdStreamSinkBuilder { + StdStreamSinkBuilder { + common_builder_impl: self.common_builder_impl, + std_stream: StdStream::Stderr, + style_mode: self.style_mode, + } + } + /// Specifies the target standard stream. /// /// This parameter is **required**.