Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
fix: disable the logger guard for now
Browse files Browse the repository at this point in the history
Closes #1184
  • Loading branch information
pjenvey committed Apr 20, 2018
1 parent 976cc60 commit ac5b688
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
4 changes: 1 addition & 3 deletions autopush_rs/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ pub struct ServerOptions {
pub close_handshake_timeout: Option<Duration>,
pub statsd_host: Option<String>,
pub statsd_port: u16,
pub logger: util::LogGuards,
pub megaphone_api_url: Option<String>,
pub megaphone_api_token: Option<String>,
pub megaphone_poll_interval: Duration,
Expand Down Expand Up @@ -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,
Expand All @@ -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"),
Expand Down
16 changes: 5 additions & 11 deletions autopush_rs/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit ac5b688

Please sign in to comment.