mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-02 04:03:35 +00:00
Update Rust Edition to 2024 (#7766)
* #7749 Thanks @dknopik and @michaelsproul for your help!
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use metrics::{try_create_int_counter, IntCounter, Result as MetricsResult};
|
||||
use metrics::{IntCounter, Result as MetricsResult, try_create_int_counter};
|
||||
use std::sync::LazyLock;
|
||||
use std::time::{Duration, Instant};
|
||||
use tracing_subscriber::EnvFilter;
|
||||
@@ -14,7 +14,7 @@ mod utils;
|
||||
|
||||
pub use sse_logging_components::SSELoggingComponents;
|
||||
pub use tracing_libp2p_discv5_logging_layer::{
|
||||
create_libp2p_discv5_tracing_layer, Libp2pDiscv5TracingLayer,
|
||||
Libp2pDiscv5TracingLayer, create_libp2p_discv5_tracing_layer,
|
||||
};
|
||||
pub use tracing_logging_layer::LoggingLayer;
|
||||
pub use tracing_metrics_layer::MetricsLayer;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! This module provides an implementation of `tracing_subscriber::layer::Layer` that optionally writes to a channel if
|
||||
//! there are subscribers to a HTTP SSE stream.
|
||||
|
||||
use serde_json::json;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::broadcast::Sender;
|
||||
use tracing::field::{Field, Visit};
|
||||
@@ -45,13 +45,12 @@ impl<S: Subscriber> Layer<S> for SSELoggingComponents {
|
||||
.get("fields")
|
||||
.and_then(|fields| fields.get("error_type"))
|
||||
.and_then(|val| val.as_str())
|
||||
&& error_type.eq_ignore_ascii_case("crit")
|
||||
{
|
||||
if error_type.eq_ignore_ascii_case("crit") {
|
||||
log_entry["level"] = json!("CRIT");
|
||||
log_entry["level"] = json!("CRIT");
|
||||
|
||||
if let Some(Value::Object(ref mut map)) = log_entry.get_mut("fields") {
|
||||
map.remove("error_type");
|
||||
}
|
||||
if let Some(Value::Object(map)) = log_entry.get_mut("fields") {
|
||||
map.remove("error_type");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,9 +72,11 @@ impl TracingEventVisitor {
|
||||
let mut log_entry = serde_json::Map::new();
|
||||
log_entry.insert(
|
||||
"time".to_string(),
|
||||
json!(chrono::Local::now()
|
||||
.format("%b %d %H:%M:%S%.3f")
|
||||
.to_string()),
|
||||
json!(
|
||||
chrono::Local::now()
|
||||
.format("%b %d %H:%M:%S%.3f")
|
||||
.to_string()
|
||||
),
|
||||
);
|
||||
log_entry.insert("level".to_string(), json!(metadata.level().to_string()));
|
||||
log_entry.insert("target".to_string(), json!(metadata.target()));
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use tracing::Subscriber;
|
||||
use tracing_appender::non_blocking::{NonBlocking, WorkerGuard};
|
||||
use tracing_subscriber::{layer::Context, Layer};
|
||||
use tracing_subscriber::{Layer, layer::Context};
|
||||
|
||||
pub struct Libp2pDiscv5TracingLayer {
|
||||
pub libp2p_non_blocking_writer: NonBlocking,
|
||||
@@ -65,11 +65,11 @@ pub fn create_libp2p_discv5_tracing_layer(
|
||||
// Ensure that `tracing_log_path` only contains directories.
|
||||
for p in tracing_log_path.clone().iter() {
|
||||
tracing_log_path = tracing_log_path.join(p);
|
||||
if let Ok(metadata) = tracing_log_path.metadata() {
|
||||
if !metadata.is_dir() {
|
||||
tracing_log_path.pop();
|
||||
break;
|
||||
}
|
||||
if let Ok(metadata) = tracing_log_path.metadata()
|
||||
&& !metadata.is_dir()
|
||||
{
|
||||
tracing_log_path.pop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ use crate::utils::is_ascii_control;
|
||||
use chrono::prelude::*;
|
||||
use serde_json::{Map, Value};
|
||||
use std::io::Write;
|
||||
use tracing::Subscriber;
|
||||
use tracing::field::Field;
|
||||
use tracing::span::Id;
|
||||
use tracing::Subscriber;
|
||||
use tracing_appender::non_blocking::{NonBlocking, WorkerGuard};
|
||||
use tracing_subscriber::Layer;
|
||||
use tracing_subscriber::layer::Context;
|
||||
use tracing_subscriber::registry::LookupSpan;
|
||||
use tracing_subscriber::Layer;
|
||||
|
||||
const FIXED_MESSAGE_WIDTH: usize = 44;
|
||||
const ALIGNED_LEVEL_WIDTH: usize = 5;
|
||||
@@ -405,7 +405,7 @@ fn parse_field(val: &str) -> Value {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::tracing_logging_layer::{build_log_text, FieldVisitor};
|
||||
use crate::tracing_logging_layer::{FieldVisitor, build_log_text};
|
||||
use std::io::Write;
|
||||
|
||||
struct Buffer {
|
||||
|
||||
@@ -5,8 +5,8 @@ use workspace_members::workspace_crates;
|
||||
const WORKSPACE_CRATES: &[&str] = workspace_crates!();
|
||||
|
||||
/// Constructs a filter which only permits logging from crates which are members of the workspace.
|
||||
pub fn build_workspace_filter(
|
||||
) -> Result<FilterFn<impl Fn(&tracing::Metadata) -> bool + Clone>, String> {
|
||||
pub fn build_workspace_filter()
|
||||
-> Result<FilterFn<impl Fn(&tracing::Metadata) -> bool + Clone>, String> {
|
||||
let workspace_crates: HashSet<&str> = WORKSPACE_CRATES.iter().copied().collect();
|
||||
|
||||
Ok(tracing_subscriber::filter::FilterFn::new(move |metadata| {
|
||||
|
||||
Reference in New Issue
Block a user