Skip to content

Commit 30bca7d

Browse files
committed
Fix impl for tests
1 parent bdad94e commit 30bca7d

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

tests/utils.rs

+20-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::{
1010
};
1111
#[cfg(feature = "enterprise")]
1212
use std::collections::HashMap;
13+
use couchbase_lite::logging::CustomLogSink;
1314

1415
pub const DB_NAME: &str = "test_db";
1516

@@ -26,9 +27,15 @@ fn logger(domain: logging::Domain, level: logging::Level, message: &str) {
2627
}
2728

2829
pub fn init_logging() {
29-
logging::set_callback(Some(logger));
30-
logging::set_callback_level(logging::Level::Verbose);
31-
logging::set_console_level(logging::Level::None);
30+
logging::set_custom_log_sink(CustomLogSink {
31+
level: logging::Level::Verbose,
32+
callback: Some(logger),
33+
domains: logging::DomainMask::ALL,
34+
});
35+
logging::set_console_log_sink(logging::ConsoleLogSink {
36+
level: logging::Level::None,
37+
domains: logging::DomainMask::ALL,
38+
});
3239
}
3340

3441
pub struct LeakChecker {
@@ -37,6 +44,12 @@ pub struct LeakChecker {
3744
end_instance_count: usize,
3845
}
3946

47+
impl Default for LeakChecker {
48+
fn default() -> Self {
49+
Self::new()
50+
}
51+
}
52+
4053
impl LeakChecker {
4154
pub fn new() -> Self {
4255
if option_env!("LEAK_CHECK").is_some() {
@@ -58,12 +71,12 @@ impl LeakChecker {
5871
impl Drop for LeakChecker {
5972
fn drop(&mut self) {
6073
if self.is_checking {
61-
info!("Checking if Couchbase Lite objects were leaked by this test");
74+
println!("Checking if Couchbase Lite objects were leaked by this test");
6275
self.end_instance_count = instance_count();
6376

6477
if self.start_instance_count != self.end_instance_count {
65-
info!("Leaks detected :-(");
66-
info!(
78+
println!("Leaks detected :-(");
79+
println!(
6780
"Instances before: {} | Instances after: {}",
6881
self.start_instance_count, self.end_instance_count
6982
);
@@ -73,7 +86,7 @@ impl Drop for LeakChecker {
7386
// default. Looking for changes in the `instance_count()` is intrinsically not thread safe.
7487
// Either run tests with `cargo test -- --test-threads`, or turn off `LEAK_CHECKS`.
7588
} else {
76-
info!("All good :-)");
89+
println!("All good :-)");
7790
}
7891
}
7992
}

0 commit comments

Comments
 (0)