use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EnhancedLoggingConfig {
pub enabled: bool,
pub log_events: bool,
pub verbosity: LogVerbosity,
pub show_account_changes: bool,
pub decode_light_instructions: bool,
pub show_compute_units: bool,
pub use_colors: bool,
pub max_inner_instruction_depth: usize,
pub show_compression_instruction_data: bool,
}
impl Default for EnhancedLoggingConfig {
fn default() -> Self {
Self {
enabled: true, log_events: false, verbosity: LogVerbosity::Standard,
show_account_changes: true,
decode_light_instructions: true,
show_compute_units: true,
use_colors: true,
max_inner_instruction_depth: 60,
show_compression_instruction_data: false,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum LogVerbosity {
Brief,
Standard,
Detailed,
Full,
}
impl EnhancedLoggingConfig {
pub fn debug() -> Self {
Self {
enabled: true,
log_events: true, verbosity: LogVerbosity::Full,
show_account_changes: true,
decode_light_instructions: true,
show_compute_units: true,
use_colors: true,
max_inner_instruction_depth: 60,
show_compression_instruction_data: false,
}
}
pub fn minimal() -> Self {
Self {
enabled: true,
log_events: false, verbosity: LogVerbosity::Brief,
show_account_changes: false,
decode_light_instructions: false,
show_compute_units: false,
use_colors: false,
max_inner_instruction_depth: 60,
show_compression_instruction_data: false,
}
}
pub fn from_env() -> Self {
if std::env::var("RUST_BACKTRACE").is_ok() {
Self::debug()
} else {
Self::default()
}
}
pub fn with_logging(mut self) -> Self {
self.log_events = true;
self
}
pub fn without_logging(mut self) -> Self {
self.log_events = false;
self
}
}