Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta compiler fix #5659

Merged
merged 9 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions common/logging/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,12 @@ pub fn create_tracing_layer(base_tracing_log_path: PathBuf) {
return;
};

let (libp2p_non_blocking_writer, libp2p_guard) = NonBlocking::new(libp2p_writer);
let (discv5_non_blocking_writer, discv5_guard) = NonBlocking::new(discv5_writer);
let (libp2p_non_blocking_writer, _) = NonBlocking::new(libp2p_writer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need the guards for the logging to actually happen. From https://docs.rs/tracing-appender/latest/tracing_appender/non_blocking/index.html

Note that the WorkerGuard returned by non_blocking must be assigned to a binding that is not _, as _ will result in the WorkerGuard being dropped immediately. Unintentional drops of WorkerGuard remove the guarantee that logs will be flushed during a program’s termination, in a panic or otherwise.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 nice catch, added back

let (discv5_non_blocking_writer, _) = NonBlocking::new(discv5_writer);

let custom_layer = LoggingLayer {
libp2p_non_blocking_writer,
libp2p_guard,
discv5_non_blocking_writer,
discv5_guard,
};

if let Err(e) = tracing_subscriber::fmt()
Expand Down
4 changes: 1 addition & 3 deletions common/logging/src/tracing_logging_layer.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use chrono::prelude::*;
use std::io::Write;
use tracing::Subscriber;
use tracing_appender::non_blocking::{NonBlocking, WorkerGuard};
use tracing_appender::non_blocking::NonBlocking;
use tracing_subscriber::layer::Context;
use tracing_subscriber::Layer;

pub struct LoggingLayer {
pub libp2p_non_blocking_writer: NonBlocking,
pub libp2p_guard: WorkerGuard,
pub discv5_non_blocking_writer: NonBlocking,
pub discv5_guard: WorkerGuard,
}

impl<S> Layer<S> for LoggingLayer
Expand Down
Loading