Skip to content

Commit

Permalink
Rename CounterSink to TestSink
Browse files Browse the repository at this point in the history
  • Loading branch information
SpriteOvO committed Jun 13, 2024
1 parent e0e8d69 commit 5cc716e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion spdlog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ mod tests {

#[test]
fn test_default_logger() {
let test_sink = Arc::new(CounterSink::new());
let test_sink = Arc::new(TestSink::new());

let test_logger = Arc::new(build_test_logger(|b| b.sink(test_sink.clone())));
let empty_logger = Arc::new(Logger::builder().build().unwrap());
Expand Down
2 changes: 1 addition & 1 deletion spdlog/src/log_crate_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ mod tests {
crate::init_log_crate_proxy().unwrap();
log::set_max_level(log::LevelFilter::Debug);

let sink = Arc::new(CounterSink::new());
let sink = Arc::new(TestSink::new());
crate::log_crate_proxy()
.set_logger(Some(Arc::new(build_test_logger(|b| b.sink(sink.clone())))));

Expand Down
8 changes: 4 additions & 4 deletions spdlog/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ mod tests {

#[test]
fn flush_level() {
let test_sink = Arc::new(CounterSink::new());
let test_sink = Arc::new(TestSink::new());
let test_logger = Logger::builder().sink(test_sink.clone()).build().unwrap();

trace!(logger: test_logger, "");
Expand Down Expand Up @@ -634,7 +634,7 @@ mod tests {

#[test]
fn periodic_flush() {
let test_sink = Arc::new(CounterSink::new());
let test_sink = Arc::new(TestSink::new());
let test_logger = Arc::new(Logger::builder().sink(test_sink.clone()).build().unwrap());

test_logger.set_flush_period(Some(Duration::from_secs(1)));
Expand Down Expand Up @@ -789,7 +789,7 @@ mod tests {

#[test]
fn fork_logger() {
let test_sink = (Arc::new(CounterSink::new()), Arc::new(CounterSink::new()));
let test_sink = (Arc::new(TestSink::new()), Arc::new(TestSink::new()));
let logger = Arc::new(build_test_logger(|b| b.sink(test_sink.0.clone())));

assert!(logger.name().is_none());
Expand Down Expand Up @@ -842,7 +842,7 @@ mod tests {
.name()
.is_none());

let test_sink = (Arc::new(CounterSink::new()), Arc::new(CounterSink::new()));
let test_sink = (Arc::new(TestSink::new()), Arc::new(TestSink::new()));
let old = Arc::new(build_test_logger(|b| b.sink(test_sink.0.clone())));
old.set_flush_period(Some(Duration::from_secs(1)));
std::thread::sleep(Duration::from_millis(1250));
Expand Down
6 changes: 3 additions & 3 deletions spdlog/src/sink/async_sink/async_pool_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ mod tests {

#[test]
fn default_thread_pool() {
let counter_sink = Arc::new(CounterSink::new());
let counter_sink = Arc::new(TestSink::new());
let build_logger = || {
build_test_logger(|b| {
b.sink(Arc::new(
Expand Down Expand Up @@ -301,7 +301,7 @@ mod tests {

#[test]
fn custom_thread_pool() {
let counter_sink = Arc::new(CounterSink::new());
let counter_sink = Arc::new(TestSink::new());
let thread_pool = Arc::new(ThreadPool::builder().build().unwrap());
let logger = build_test_logger(|b| {
b.sink(Arc::new(
Expand Down Expand Up @@ -336,7 +336,7 @@ mod tests {

#[test]
fn async_opeartions() {
let counter_sink = Arc::new(CounterSink::with_delay(Some(Duration::from_secs(1))));
let counter_sink = Arc::new(TestSink::with_delay(Some(Duration::from_secs(1))));
// The default thread pool is not used here to avoid race when tests are run in
// parallel.
let thread_pool = Arc::new(ThreadPool::builder().build().unwrap());
Expand Down
2 changes: 1 addition & 1 deletion spdlog/src/sink/dedup_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ mod tests {

#[test]
fn dedup() {
let test_sink = Arc::new(CounterSink::new());
let test_sink = Arc::new(TestSink::new());
let dedup_sink = Arc::new(
DedupSink::builder()
.skip_duration(Duration::from_secs(1))
Expand Down
8 changes: 4 additions & 4 deletions spdlog/src/test_utils/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ use spdlog::{

//////////////////////////////////////////////////

pub struct CounterSink {
pub struct TestSink {
level_filter: Atomic<LevelFilter>,
log_counter: AtomicUsize,
flush_counter: AtomicUsize,
records: Mutex<Vec<RecordOwned>>,
delay_duration: Option<Duration>,
}

impl CounterSink {
impl TestSink {
#[must_use]
pub fn new() -> Self {
Self::with_delay(None)
Expand Down Expand Up @@ -81,7 +81,7 @@ impl CounterSink {
}
}

impl Sink for CounterSink {
impl Sink for TestSink {
fn log(&self, record: &Record) -> Result<()> {
if let Some(delay) = self.delay_duration {
sleep(delay);
Expand Down Expand Up @@ -119,7 +119,7 @@ impl Sink for CounterSink {
}
}

impl Default for CounterSink {
impl Default for TestSink {
fn default() -> Self {
Self::new()
}
Expand Down

0 comments on commit 5cc716e

Please sign in to comment.