From 27af6965bd0f71c47600f4ccc1c127d63f132ed7 Mon Sep 17 00:00:00 2001 From: Philip Jenvey Date: Fri, 20 Apr 2018 16:05:13 -0700 Subject: [PATCH] fix: disable the logger guard for now Closes #1184 --- autopush_rs/src/server/mod.rs | 4 +--- autopush_rs/src/util/mod.rs | 16 +++++----------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/autopush_rs/src/server/mod.rs b/autopush_rs/src/server/mod.rs index bd1e1547..57be007f 100644 --- a/autopush_rs/src/server/mod.rs +++ b/autopush_rs/src/server/mod.rs @@ -116,7 +116,6 @@ pub struct ServerOptions { pub close_handshake_timeout: Option, pub statsd_host: Option, pub statsd_port: u16, - pub logger: util::LogGuards, pub megaphone_api_url: Option, pub megaphone_api_token: Option, pub megaphone_poll_interval: Duration, @@ -157,7 +156,7 @@ pub extern "C" fn autopush_server_new( rt::catch(err, || unsafe { let opts = &*opts; - let logger = util::init_logging(opts.json_logging != 0); + util::init_logging(opts.json_logging != 0); let opts = ServerOptions { debug: opts.debug != 0, port: opts.port, @@ -178,7 +177,6 @@ pub extern "C" fn autopush_server_new( Some(opts.max_connections) }, open_handshake_timeout: ito_dur(opts.open_handshake_timeout), - logger: logger, megaphone_api_url: to_s(opts.megaphone_api_url).map(|s| s.to_string()), megaphone_api_token: to_s(opts.megaphone_api_token).map(|s| s.to_string()), megaphone_poll_interval: ito_dur(opts.megaphone_poll_interval).expect("poll interval cannot be 0"), diff --git a/autopush_rs/src/util/mod.rs b/autopush_rs/src/util/mod.rs index 97bf159c..1d4d2bf8 100644 --- a/autopush_rs/src/util/mod.rs +++ b/autopush_rs/src/util/mod.rs @@ -52,13 +52,7 @@ where })) } -// Hold a reference to the log guards for scoped logging which requires these to stay alive -// for the implicit logger to be passed into logging calls -pub struct LogGuards { - _scope_guard: slog_scope::GlobalLoggerGuard, -} - -pub fn init_logging(json: bool) -> LogGuards { +pub fn init_logging(json: bool) { let instance_id_or_hostname = if json { get_ec2_instance_id().unwrap_or_else(|_| get_hostname().expect("Couldn't get_hostname")) } else { @@ -91,11 +85,11 @@ pub fn init_logging(json: bool) -> LogGuards { ), ) }; - let _scope_guard = slog_scope::set_global_logger(logger); + // 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 + slog_scope::set_global_logger(logger).cancel_reset(); slog_stdlog::init().ok(); - LogGuards { - _scope_guard: _scope_guard, - } } pub fn reset_logging() {