mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +08:00
chore: address Rust 1.83.0 clippy lints and enable more clippy lints (#6705)
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
#![warn(missing_debug_implementations)]
|
||||
|
||||
//!
|
||||
//! Environment of payment router: logger, basic config, its environment awareness.
|
||||
//!
|
||||
|
||||
#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR" ), "/", "README.md"))]
|
||||
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! Logger of the system.
|
||||
//!
|
||||
|
||||
pub use tracing::{debug, error, event as log, info, warn};
|
||||
pub use tracing_attributes::instrument;
|
||||
@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! Logger-specific config.
|
||||
//!
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! Formatting [layer](https://docs.rs/tracing-subscriber/0.3.15/tracing_subscriber/layer/trait.Layer.html) for Router.
|
||||
//!
|
||||
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
@ -117,10 +115,8 @@ impl fmt::Display for RecordType {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Format log records.
|
||||
/// `FormattingLayer` relies on the `tracing_bunyan_formatter::JsonStorageLayer` which is storage of entries.
|
||||
///
|
||||
#[derive(Debug)]
|
||||
pub struct FormattingLayer<W, F>
|
||||
where
|
||||
@ -145,7 +141,6 @@ where
|
||||
W: for<'a> MakeWriter<'a> + 'static,
|
||||
F: Formatter + Clone,
|
||||
{
|
||||
///
|
||||
/// Constructor of `FormattingLayer`.
|
||||
///
|
||||
/// A `name` will be attached to all records during formatting.
|
||||
@ -155,7 +150,6 @@ where
|
||||
/// ```rust
|
||||
/// let formatting_layer = router_env::FormattingLayer::new("my_service", std::io::stdout, serde_json::ser::CompactFormatter);
|
||||
/// ```
|
||||
///
|
||||
pub fn new(
|
||||
service: &str,
|
||||
dst_writer: W,
|
||||
@ -296,11 +290,9 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// Flush memory buffer into an output stream trailing it with next line.
|
||||
///
|
||||
/// Should be done by single `write_all` call to avoid fragmentation of log because of mutlithreading.
|
||||
///
|
||||
fn flush(&self, mut buffer: Vec<u8>) -> Result<(), std::io::Error> {
|
||||
buffer.write_all(b"\n")?;
|
||||
self.dst_writer.make_writer().write_all(&buffer)
|
||||
@ -361,12 +353,9 @@ where
|
||||
Ok(buffer)
|
||||
}
|
||||
|
||||
///
|
||||
/// Format message of a span.
|
||||
///
|
||||
/// Example: "[FN_WITHOUT_COLON - START]"
|
||||
///
|
||||
|
||||
fn span_message<S>(span: &SpanRef<'_, S>, ty: RecordType) -> String
|
||||
where
|
||||
S: Subscriber + for<'a> LookupSpan<'a>,
|
||||
@ -374,12 +363,9 @@ where
|
||||
format!("[{} - {}]", span.metadata().name().to_uppercase(), ty)
|
||||
}
|
||||
|
||||
///
|
||||
/// Format message of an event.
|
||||
///
|
||||
/// Examples: "[FN_WITHOUT_COLON - EVENT] Message"
|
||||
///
|
||||
|
||||
fn event_message<S>(
|
||||
span: &Option<&SpanRef<'_, S>>,
|
||||
event: &Event<'_>,
|
||||
|
||||
@ -181,9 +181,7 @@ struct TraceAssertion {
|
||||
}
|
||||
|
||||
impl TraceAssertion {
|
||||
///
|
||||
/// Should the provided url be traced
|
||||
///
|
||||
fn should_trace_url(&self, url: &str) -> bool {
|
||||
match &self.clauses {
|
||||
Some(clauses) => clauses.iter().all(|cur| cur.compare_url(url)),
|
||||
@ -192,9 +190,7 @@ impl TraceAssertion {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Conditional Sampler for providing control on url based tracing
|
||||
///
|
||||
#[derive(Clone, Debug)]
|
||||
struct ConditionalSampler<T: trace::ShouldSample + Clone + 'static>(TraceAssertion, T);
|
||||
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! Storing [layer](https://docs.rs/tracing-subscriber/0.3.15/tracing_subscriber/layer/trait.Layer.html) for Router.
|
||||
//!
|
||||
|
||||
use std::{collections::HashMap, fmt, time::Instant};
|
||||
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! Types.
|
||||
//!
|
||||
|
||||
use serde::Deserialize;
|
||||
use strum::{Display, EnumString};
|
||||
@ -9,12 +7,9 @@ pub use tracing::{
|
||||
Level, Value,
|
||||
};
|
||||
|
||||
///
|
||||
/// Category and tag of log event.
|
||||
///
|
||||
/// Don't hesitate to add your variant if it is missing here.
|
||||
///
|
||||
|
||||
#[derive(Debug, Default, Deserialize, Clone, Display, EnumString)]
|
||||
pub enum Tag {
|
||||
/// General.
|
||||
@ -516,9 +511,7 @@ pub enum Flow {
|
||||
PaymentStartRedirection,
|
||||
}
|
||||
|
||||
///
|
||||
/// Trait for providing generic behaviour to flow metric
|
||||
///
|
||||
pub trait FlowMetric: ToString + std::fmt::Debug + Clone {}
|
||||
impl FlowMetric for Flow {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user