1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#![deny(
missing_docs,
trivial_casts,
trivial_numeric_casts,
unused_extern_crates,
unused_import_braces,
unused_results
)]
use simplelog::{ConfigBuilder, LevelFilter, SimpleLogger};
use std::sync::Once;
pub mod average;
pub mod config;
pub mod fmt;
pub mod platform;
pub mod server;
pub mod signals;
pub const APOLLO_VERSION: &str = "0.3.0";
pub const APOLLO_REVISION: &str = "6f221e091750dc8a717c93b0463bd843abdbfd58";
pub fn init_logging() {
static INIT_LOGGING: Once = Once::new();
static DATE_FORMAT: &str = "[%Y-%m-%dT%H:%M:%S%.3f]";
INIT_LOGGING.call_once(|| {
if let Err(error) = SimpleLogger::init(
LevelFilter::Debug,
ConfigBuilder::new()
.set_time_format_str(DATE_FORMAT)
.set_thread_level(LevelFilter::Trace)
.set_target_level(LevelFilter::Error)
.set_location_level(LevelFilter::Trace)
.build(),
) {
panic!("Failed to initialize logging system: {}", error);
}
});
}
#[cfg(test)]
mod testing {
use std::sync::Mutex;
lazy_static::lazy_static! {
pub static ref SHARED_TEST_RESOURCES: Mutex<()> = Mutex::new(());
}
pub fn test_async<F: std::future::Future>(future: F) {
use tokio::runtime;
let rt = runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
let _ = rt.block_on(future);
}
}