@@ -10,6 +10,7 @@ use std::{
10
10
} ;
11
11
#[ cfg( feature = "enterprise" ) ]
12
12
use std:: collections:: HashMap ;
13
+ use couchbase_lite:: logging:: CustomLogSink ;
13
14
14
15
pub const DB_NAME : & str = "test_db" ;
15
16
@@ -26,9 +27,15 @@ fn logger(domain: logging::Domain, level: logging::Level, message: &str) {
26
27
}
27
28
28
29
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
+ } ) ;
32
39
}
33
40
34
41
pub struct LeakChecker {
@@ -37,6 +44,12 @@ pub struct LeakChecker {
37
44
end_instance_count : usize ,
38
45
}
39
46
47
+ impl Default for LeakChecker {
48
+ fn default ( ) -> Self {
49
+ Self :: new ( )
50
+ }
51
+ }
52
+
40
53
impl LeakChecker {
41
54
pub fn new ( ) -> Self {
42
55
if option_env ! ( "LEAK_CHECK" ) . is_some ( ) {
@@ -58,12 +71,12 @@ impl LeakChecker {
58
71
impl Drop for LeakChecker {
59
72
fn drop ( & mut self ) {
60
73
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" ) ;
62
75
self . end_instance_count = instance_count ( ) ;
63
76
64
77
if self . start_instance_count != self . end_instance_count {
65
- info ! ( "Leaks detected :-(" ) ;
66
- info ! (
78
+ println ! ( "Leaks detected :-(" ) ;
79
+ println ! (
67
80
"Instances before: {} | Instances after: {}" ,
68
81
self . start_instance_count, self . end_instance_count
69
82
) ;
@@ -73,7 +86,7 @@ impl Drop for LeakChecker {
73
86
// default. Looking for changes in the `instance_count()` is intrinsically not thread safe.
74
87
// Either run tests with `cargo test -- --test-threads`, or turn off `LEAK_CHECKS`.
75
88
} else {
76
- info ! ( "All good :-)" ) ;
89
+ println ! ( "All good :-)" ) ;
77
90
}
78
91
}
79
92
}
0 commit comments