mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
fix(router_env): resolve/remove FIXME's and redundent files (#168)
This commit is contained in:
@ -115,22 +115,15 @@ impl Config {
|
||||
let environment = crate::env::which();
|
||||
let config_path = Self::config_path(&environment.to_string(), explicit_config_path);
|
||||
|
||||
// println!(
|
||||
// "config_path : {:?} {:?}",
|
||||
// config_path,
|
||||
// std::path::Path::new(&config_path).exists()
|
||||
// );
|
||||
|
||||
let config = Self::builder(&environment.to_string())?
|
||||
.add_source(config::File::from(config_path).required(true))
|
||||
.add_source(config::Environment::with_prefix("ROUTER").separator("__"))
|
||||
.build()?;
|
||||
// FIXME: in case config is missing information about error is not readable
|
||||
|
||||
config.try_deserialize().map_err(|e| {
|
||||
crate::error!("Unable to source config file");
|
||||
eprintln!("Unable to source config file");
|
||||
e
|
||||
serde_path_to_error::deserialize(config).map_err(|error| {
|
||||
crate::error!(%error, "Unable to deserialize configuration");
|
||||
eprintln!("Unable to deserialize application configuration: {error}");
|
||||
error.into_inner()
|
||||
})
|
||||
}
|
||||
|
||||
@ -144,6 +137,7 @@ impl Config {
|
||||
// Should be single source of truth.
|
||||
.set_override("env", environment)?
|
||||
.add_source(config::File::from_str(
|
||||
// Plan on handling with the changes in crates/router
|
||||
// FIXME: embedding of textual file into bin files has several disadvantages
|
||||
// 1. larger bin file
|
||||
// 2. slower initialization of program
|
||||
|
||||
@ -22,8 +22,7 @@ use tracing_subscriber::{
|
||||
};
|
||||
|
||||
use crate::Storage;
|
||||
|
||||
// FIXME: xxx: Describe each implicit field with examples.
|
||||
// TODO: Documentation coverage for this crate
|
||||
|
||||
// Implicit keys
|
||||
|
||||
@ -52,14 +51,6 @@ const REQUEST_METHOD: &str = "request_method";
|
||||
const REQUEST_URL_PATH: &str = "request_url_path";
|
||||
const REQUEST_ID: &str = "request_id";
|
||||
|
||||
//const TAG: &str = "tag";
|
||||
//const CATEGORY: &str = "category";
|
||||
//const SESSION_ID: &str = "session_id";
|
||||
//const PAYMENT_ID: &str = "payment_id";
|
||||
//const PAYMENT_ATTEMPT_ID: &str = "payment_attempt_id";
|
||||
//const MERCHANT_ID: &str = "merchant_id";
|
||||
//const FLOW: &str = "flow";
|
||||
|
||||
/// Set of predefined implicit keys.
|
||||
pub static IMPLICIT_KEYS: Lazy<rustc_hash::FxHashSet<&str>> = Lazy::new(|| {
|
||||
let mut set = rustc_hash::FxHashSet::default();
|
||||
|
||||
@ -1,104 +0,0 @@
|
||||
//!
|
||||
//! Macros.
|
||||
//!
|
||||
|
||||
pub use crate::log;
|
||||
|
||||
///
|
||||
/// Make a new log Event.
|
||||
///
|
||||
/// The event macro is invoked with a Level and up to 32 key-value fields.
|
||||
/// Optionally, a format string and arguments may follow the fields; this will be used to construct an implicit field named “message”.
|
||||
/// See the top-level [documentation of tracing](https://docs.rs/tracing/latest/tracing/index.html#using-the-macros) for details on the syntax accepted by this macro.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// // FIXME: write
|
||||
/// ```
|
||||
///
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! log {
|
||||
|
||||
// done
|
||||
|
||||
(
|
||||
@MUNCH
|
||||
{
|
||||
level : { $level:ident },
|
||||
tag : { $tag:ident },
|
||||
category : { $category:ident },
|
||||
flow : { $flow:expr },
|
||||
// $( session_id : { $session_id:expr }, )?
|
||||
// $( payment_id : { $payment_id:expr }, )?
|
||||
// $( payment_attempt_id : { $payment_attempt_id:expr }, )?
|
||||
// $( merchant_id : { $merchant_id:expr }, )?
|
||||
},
|
||||
$( $tail:tt )*
|
||||
)
|
||||
=>
|
||||
(
|
||||
::tracing::event!
|
||||
(
|
||||
::router_env::Level::$level,
|
||||
level = ?::router_env::Level::$level,
|
||||
tag = ?::router_env::Tag::$tag,
|
||||
category = ?::router_env::Category::$category,
|
||||
flow = ?$flow,
|
||||
// $( session_id = $session_id, )?
|
||||
// $( payment_id = $payment_id, )?
|
||||
// $( payment_attempt_id = $payment_attempt_id, )?
|
||||
// $( merchant_id = $merchant_id, )?
|
||||
$( $tail )*
|
||||
);
|
||||
);
|
||||
|
||||
// entry with colon
|
||||
|
||||
(
|
||||
level : $level:ident,
|
||||
tag : $tag:ident,
|
||||
category : $category:ident,
|
||||
flow : $(?)?$flow:expr,
|
||||
$( $tail:tt )*
|
||||
)
|
||||
=>
|
||||
(
|
||||
$crate::log!
|
||||
{
|
||||
@MUNCH
|
||||
{
|
||||
level : { $level },
|
||||
tag : { $tag },
|
||||
category : { $category },
|
||||
flow : { $flow },
|
||||
},
|
||||
$( $tail )*
|
||||
}
|
||||
);
|
||||
|
||||
// entry without colon
|
||||
|
||||
(
|
||||
$level:ident,
|
||||
$tag:ident,
|
||||
$category:ident,
|
||||
$flow:expr,
|
||||
$( $tail:tt )*
|
||||
)
|
||||
=>
|
||||
(
|
||||
$crate::log!
|
||||
{
|
||||
@MUNCH
|
||||
{
|
||||
level : { $level },
|
||||
tag : { $tag },
|
||||
category : { $category },
|
||||
flow : { $flow },
|
||||
},
|
||||
$( $tail )*
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
@ -22,30 +22,6 @@ use tracing_subscriber::{
|
||||
|
||||
use crate::{config, FormattingLayer, Level, StorageSubscription};
|
||||
|
||||
// FIXME: xxx: clean
|
||||
pub struct DebugLayer;
|
||||
impl<S> Layer<S> for DebugLayer
|
||||
where
|
||||
S: tracing::Subscriber,
|
||||
{
|
||||
fn on_event(
|
||||
&self,
|
||||
event: &tracing::Event<'_>,
|
||||
_ctx: tracing_subscriber::layer::Context<'_, S>,
|
||||
) {
|
||||
if event.metadata().level() == &Level::TRACE {
|
||||
return;
|
||||
}
|
||||
println!("Got event!");
|
||||
println!(" level={:?}", event.metadata().level());
|
||||
println!(" target={:?}", event.metadata().target());
|
||||
println!(" name={:?}", event.metadata().name());
|
||||
for field in event.fields() {
|
||||
println!(" field={}", field.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// TelemetryGuard which helps with
|
||||
#[derive(Debug)]
|
||||
pub struct TelemetryGuard {
|
||||
|
||||
Reference in New Issue
Block a user