diff --git a/Cargo.lock b/Cargo.lock index a355f4533f..f5e412802a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -712,7 +712,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" dependencies = [ "serde 1.0.195", - "uuid", + "uuid 1.7.0", ] [[package]] @@ -798,27 +798,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "dirs-next" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" -dependencies = [ - "cfg-if", - "dirs-sys-next", -] - -[[package]] -name = "dirs-sys-next" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - [[package]] name = "docopt" version = "1.1.1" @@ -884,15 +863,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "erased-serde" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" -dependencies = [ - "serde 1.0.195", -] - [[package]] name = "errno" version = "0.3.8" @@ -1067,6 +1037,16 @@ dependencies = [ "version_check", ] +[[package]] +name = "gethostname" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "getrandom" version = "0.2.12" @@ -1492,17 +1472,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "libredox" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" -dependencies = [ - "bitflags 2.4.2", - "libc", - "redox_syscall", -] - [[package]] name = "libz-sys" version = "1.1.14" @@ -1566,6 +1535,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "matches" version = "0.1.10" @@ -1708,6 +1686,16 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-traits" version = "0.1.43" @@ -1736,15 +1724,6 @@ dependencies = [ "libc", ] -[[package]] -name = "num_threads" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" -dependencies = [ - "libc", -] - [[package]] name = "object" version = "0.32.2" @@ -1815,6 +1794,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "parking_lot" version = "0.12.1" @@ -1862,6 +1847,26 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "pin-project" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "pin-project-lite" version = "0.2.13" @@ -2051,17 +2056,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "redox_users" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" -dependencies = [ - "getrandom", - "libredox", - "thiserror", -] - [[package]] name = "regex" version = "1.10.2" @@ -2070,8 +2064,17 @@ checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", ] [[package]] @@ -2082,9 +2085,15 @@ checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.2", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.8.2" @@ -2234,12 +2243,6 @@ dependencies = [ "untrusted 0.9.0", ] -[[package]] -name = "rustversion" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" - [[package]] name = "ryu" version = "1.0.16" @@ -2424,7 +2427,7 @@ dependencies = [ "thiserror", "time", "url 2.5.0", - "uuid", + "uuid 1.7.0", ] [[package]] @@ -2510,6 +2513,15 @@ dependencies = [ "digest", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "1.2.0" @@ -2539,48 +2551,6 @@ name = "slog" version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06" -dependencies = [ - "erased-serde", -] - -[[package]] -name = "slog-async" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c8038f898a2c79507940990f05386455b3a317d8f18d4caea7cbc3d5096b84" -dependencies = [ - "crossbeam-channel", - "slog", - "take_mut", - "thread_local", -] - -[[package]] -name = "slog-envlogger" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "906a1a0bc43fed692df4b82a5e2fbfc3733db8dad8bb514ab27a4f23ad04f5c0" -dependencies = [ - "log", - "regex", - "slog", - "slog-async", - "slog-scope", - "slog-stdlog", - "slog-term", -] - -[[package]] -name = "slog-mozlog-json" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f400f1c5db96f1f52065e8931ca0c524cceb029f7537c9e6d5424488ca137ca0" -dependencies = [ - "chrono", - "serde 1.0.195", - "serde_json", - "slog", -] [[package]] name = "slog-scope" @@ -2593,30 +2563,6 @@ dependencies = [ "slog", ] -[[package]] -name = "slog-stdlog" -version = "4.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6706b2ace5bbae7291d3f8d2473e2bfab073ccd7d03670946197aec98471fa3e" -dependencies = [ - "log", - "slog", - "slog-scope", -] - -[[package]] -name = "slog-term" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87d29185c55b7b258b4f120eab00f48557d4d9bc814f41713f449d35b0f8977c" -dependencies = [ - "atty", - "slog", - "term", - "thread_local", - "time", -] - [[package]] name = "smallvec" version = "1.13.0" @@ -2734,12 +2680,7 @@ dependencies = [ "serde_json", "sha2", "slog", - "slog-async", - "slog-envlogger", - "slog-mozlog-json", "slog-scope", - "slog-stdlog", - "slog-term", "syncserver-common", "syncserver-db-common", "syncserver-settings", @@ -2752,6 +2693,10 @@ dependencies = [ "tokenserver-db", "tokenserver-settings", "tokio", + "tracing", + "tracing-actix-web-mozlog", + "tracing-slog", + "tracing-subscriber", "urlencoding", "validator", "validator_derive", @@ -2900,7 +2845,7 @@ dependencies = [ "thiserror", "tokio", "url 2.5.0", - "uuid", + "uuid 1.7.0", ] [[package]] @@ -2924,12 +2869,6 @@ dependencies = [ "libc", ] -[[package]] -name = "take_mut" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" - [[package]] name = "target-lexicon" version = "0.12.13" @@ -2949,17 +2888,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "term" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" -dependencies = [ - "dirs-next", - "rustversion", - "winapi", -] - [[package]] name = "termcolor" version = "1.4.1" @@ -3016,8 +2944,6 @@ checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" dependencies = [ "deranged", "itoa", - "libc", - "num_threads", "powerfmt", "serde 1.0.195", "time-core", @@ -3204,9 +3130,70 @@ checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-actix-web" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99bcebac55fba44eadf75a424ee403e756f9165596a613d125876388e5fb4c34" +dependencies = [ + "actix-web", + "pin-project", + "tracing", + "tracing-futures", + "uuid 0.8.2", +] + +[[package]] +name = "tracing-actix-web-mozlog" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ff47cd44988a34610360846743a4a1a2a318d84f2b16810d77b119a662c4634" +dependencies = [ + "actix-web", + "futures-util", + "gethostname", + "serde 1.0.195", + "serde_json", + "tracing", + "tracing-actix-web", + "tracing-bunyan-formatter", + "tracing-futures", + "tracing-subscriber", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "tracing-bunyan-formatter" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5c266b9ac83dedf0e0385ad78514949e6d89491269e7065bee51d2bb8ec7373" +dependencies = [ + "ahash", + "gethostname", + "log", + "serde 1.0.195", + "serde_json", + "time", + "tracing", + "tracing-core", + "tracing-log 0.1.4", + "tracing-subscriber", +] + [[package]] name = "tracing-core" version = "0.1.32" @@ -3217,13 +3204,65 @@ dependencies = [ "valuable", ] +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project", + "tracing", +] + +[[package]] +name = "tracing-log" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-slog" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ffd12d2d54fb99df994fde4e3320959e32208420bfe375a664c5d8cd894a23b" +dependencies = [ + "once_cell", + "slog", + "tracing-core", +] + [[package]] name = "tracing-subscriber" version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", "tracing-core", + "tracing-log 0.2.0", ] [[package]] @@ -3334,6 +3373,15 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom", +] + [[package]] name = "uuid" version = "1.7.0" diff --git a/Cargo.toml b/Cargo.toml index fd875a0709..4f8999cd15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,13 +55,12 @@ slog = { version = "2.5", features = [ "release_max_level_info", "dynamic-keys", ] } -slog-async = "2.5" -slog-envlogger = "2.2.0" -slog-mozlog-json = "0.1" slog-scope = "4.3" -slog-stdlog = "4.1" -slog-term = "2.6" tokio = "1" +tracing = "0.1.40" +tracing-actix-web-mozlog = "0.5.0" +tracing-slog = "0.2.0" +tracing-subscriber = { version = "0.3.18", features = ["ansi", "env-filter", "registry", "std", "tracing-log"] } [profile.release] # Enables line numbers in Sentry reporting diff --git a/syncserver/Cargo.toml b/syncserver/Cargo.toml index 8b715057dc..1b32a330ce 100644 --- a/syncserver/Cargo.toml +++ b/syncserver/Cargo.toml @@ -26,12 +26,11 @@ serde_derive.workspace = true serde_json.workspace = true sha2.workspace = true slog.workspace = true -slog-async.workspace = true -slog-envlogger.workspace = true -slog-mozlog-json.workspace = true slog-scope.workspace = true -slog-stdlog.workspace = true -slog-term.workspace = true +tracing.workspace = true +tracing-slog.workspace = true +tracing-subscriber.workspace = true +tracing-actix-web-mozlog.workspace = true actix-http = "3" actix-rt = "2" diff --git a/syncserver/src/error.rs b/syncserver/src/error.rs index fc0c53b11f..278c23c648 100644 --- a/syncserver/src/error.rs +++ b/syncserver/src/error.rs @@ -167,6 +167,12 @@ impl From for ApiError { } } +impl From for ApiError { + fn from(_: tracing::subscriber::SetGlobalDefaultError) -> Self { + ApiErrorKind::Internal("Logging failed to initialize".to_string()).into() + } +} + impl From for ApiError { fn from(kind: ApiErrorKind) -> Self { let status = match &kind { diff --git a/syncserver/src/logging.rs b/syncserver/src/logging.rs index b182fa65f7..98cd84836f 100644 --- a/syncserver/src/logging.rs +++ b/syncserver/src/logging.rs @@ -1,46 +1,65 @@ -use std::io; - +use std::sync::Once; use crate::error::ApiResult; +use slog::{self, slog_o}; +use tracing::Level; +use tracing_actix_web_mozlog::{JsonStorageLayer, MozLogFormatLayer}; +use tracing_subscriber::{prelude::*, EnvFilter}; -use slog::{self, slog_o, Drain}; -use slog_mozlog_json::MozLogJson; - +/// Initialize logging for the main process +/// +/// This sets the global tracing subscriber and must only be called once at startup time. +/// Subsequent calls will panic. pub fn init_logging(json: bool) -> ApiResult<()> { - let logger = if json { - let hostname = hostname::get() - .expect("Couldn't get hostname") - .into_string() - .expect("Couldn't get hostname"); - - let drain = MozLogJson::new(io::stdout()) - .logger_name(format!( - "{}-{}", - env!("CARGO_PKG_NAME"), - env!("CARGO_PKG_VERSION") - )) - .msg_type(format!("{}:log", env!("CARGO_PKG_NAME"))) - .hostname(hostname) - .build() - .fuse(); - let drain = slog_envlogger::new(drain); - let drain = slog_async::Async::new(drain).build().fuse(); - slog::Logger::root(drain, slog_o!()) + if json { + tracing::subscriber::set_global_default(json_subscriber())?; } else { - let decorator = slog_term::TermDecorator::new().build(); - let drain = slog_term::FullFormat::new(decorator).build().fuse(); - let drain = slog_envlogger::new(drain); - let drain = slog_async::Async::new(drain).build().fuse(); - slog::Logger::root(drain, slog_o!()) + tracing::subscriber::set_global_default(human_subscriber())?; }; - // XXX: cancel slog_scope's NoGlobalLoggerSet for now, it's difficult to - // prevent it from potentially panicing during tests. reset_logging resets - // the global logger during shutdown anyway: - // https://github.com/slog-rs/slog/issues/169 - slog_scope::set_global_logger(logger).cancel_reset(); - slog_stdlog::init().ok(); + init_slog_drain(); Ok(()) } +/// Initialize logging for the tests +/// +/// Returns a DefaultGuard that must be kept alive for the duration of the test +pub fn init_test_logging() -> tracing::subscriber::DefaultGuard { + init_slog_drain(); + tracing::subscriber::set_default(human_subscriber()) +} + +fn json_subscriber() -> impl tracing::Subscriber + Send + Sync + 'static { + tracing_subscriber::registry() + .with(JsonStorageLayer) + .with(MozLogFormatLayer::new( + format!("{}-{}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")), + std::io::stdout, + )) + .with(EnvFilter::from_default_env()) +} + +fn human_subscriber() -> impl tracing::Subscriber + Send + Sync + 'static { + tracing_subscriber::fmt() + .pretty() + .with_ansi(true) + .with_max_level(Level::TRACE) + .with_env_filter(EnvFilter::from_default_env()) + .finish() +} + +fn init_slog_drain() { + static ONCE: Once = Once::new(); + + ONCE.call_once(|| { + let drain = tracing_slog::TracingSlogDrain; + let logger = slog::Logger::root(drain, slog_o!()); + // XXX: cancel slog_scope's NoGlobalLoggerSet for now, it's difficult to + // prevent it from potentially panicing during tests. reset_logging resets + // the global logger during shutdown anyway: + // https://github.com/slog-rs/slog/issues/169 + slog_scope::set_global_logger(logger).cancel_reset(); + }); +} + pub fn reset_logging() { let logger = slog::Logger::root(slog::Discard, slog_o!()); slog_scope::set_global_logger(logger).cancel_reset(); diff --git a/syncserver/src/server/mod.rs b/syncserver/src/server/mod.rs index 2c05999ccf..3dd971f3f0 100644 --- a/syncserver/src/server/mod.rs +++ b/syncserver/src/server/mod.rs @@ -72,7 +72,7 @@ pub struct Server; #[macro_export] macro_rules! build_app { - ($syncstorage_state: expr, $tokenserver_state: expr, $secrets: expr, $limits: expr, $cors: expr) => { + ($syncstorage_state: expr, $tokenserver_state: expr, $secrets: expr, $limits: expr, $cors: expr, $moz_log: expr) => { App::new() .configure(|cfg| { cfg.app_data(Data::new($syncstorage_state)); @@ -92,6 +92,7 @@ macro_rules! build_app { .wrap_fn(middleware::sentry::report_error) .wrap_fn(middleware::rejectua::reject_user_agent) .wrap($cors) + .wrap($moz_log) .wrap_fn(middleware::emit_http_status_with_tokenserver_origin) .service( web::resource(&cfg_path("/info/collections")) @@ -293,6 +294,8 @@ impl Server { None }; + let moz_log = tracing_actix_web_mozlog::MozLog::default(); + let mut server = HttpServer::new(move || { let syncstorage_state = ServerState { db_pool: Box::new(db_pool.clone()), @@ -309,7 +312,8 @@ impl Server { tokenserver_state.clone(), Arc::clone(&secrets), limits, - build_cors(&settings_copy) + build_cors(&settings_copy), + moz_log.clone() ) }); diff --git a/syncserver/src/server/test.rs b/syncserver/src/server/test.rs index ec09879196..6647a9e987 100644 --- a/syncserver/src/server/test.rs +++ b/syncserver/src/server/test.rs @@ -102,6 +102,38 @@ async fn get_test_state(settings: &Settings) -> ServerState { } } +/// Wrapper around an `actix_web::Service` used to run the tests. +/// +/// It also stores the tracing subscriber guard to ensure that logging is setup while running the +/// test. +struct TestService { + service: S, + _subscriber_guard: tracing::subscriber::DefaultGuard, +} + +impl TestService { + fn new(service: S) -> Self { + Self { + service, + _subscriber_guard: crate::logging::init_test_logging(), + } + } +} + +impl std::ops::Deref for TestService { + type Target = S; + + fn deref(&self) -> &S { + &self.service + } +} + +impl std::ops::DerefMut for TestService { + fn deref_mut(&mut self) -> &mut S { + &mut self.service + } +} + macro_rules! init_app { () => { async { @@ -111,17 +143,18 @@ macro_rules! init_app { }; ($settings:expr) => { async { - crate::logging::init_logging(false).unwrap(); let limits = Arc::new($settings.syncstorage.limits.clone()); let state = get_test_state(&$settings).await; - test::init_service(build_app!( - state, - None::, - Arc::clone(&SECRETS), - limits, - build_cors(&$settings) - )) - .await + TestService::new( + test::init_service(build_app!( + state, + None::, + Arc::clone(&SECRETS), + limits, + build_cors(&$settings) + )) + .await + ) } }; }