light_program_test/logging/
config.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct EnhancedLoggingConfig {
8 pub enabled: bool,
10 pub log_events: bool,
12 pub verbosity: LogVerbosity,
14 pub show_account_changes: bool,
16 pub decode_light_instructions: bool,
18 pub show_compute_units: bool,
20 pub use_colors: bool,
22 pub max_inner_instruction_depth: usize,
24 pub show_compression_instruction_data: bool,
26}
27
28impl Default for EnhancedLoggingConfig {
29 fn default() -> Self {
30 Self {
31 enabled: true, log_events: false, verbosity: LogVerbosity::Standard,
34 show_account_changes: true,
35 decode_light_instructions: true,
36 show_compute_units: true,
37 use_colors: true,
38 max_inner_instruction_depth: 60,
39 show_compression_instruction_data: false,
40 }
41 }
42}
43
44#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
46pub enum LogVerbosity {
47 Brief,
49 Standard,
51 Detailed,
53 Full,
55}
56
57impl EnhancedLoggingConfig {
58 pub fn debug() -> Self {
60 Self {
61 enabled: true,
62 log_events: true, verbosity: LogVerbosity::Full,
64 show_account_changes: true,
65 decode_light_instructions: true,
66 show_compute_units: true,
67 use_colors: true,
68 max_inner_instruction_depth: 60,
69 show_compression_instruction_data: false,
70 }
71 }
72
73 pub fn minimal() -> Self {
75 Self {
76 enabled: true,
77 log_events: false, verbosity: LogVerbosity::Brief,
79 show_account_changes: false,
80 decode_light_instructions: false,
81 show_compute_units: false,
82 use_colors: false,
83 max_inner_instruction_depth: 60,
84 show_compression_instruction_data: false,
85 }
86 }
87
88 pub fn from_env() -> Self {
90 if std::env::var("RUST_BACKTRACE").is_ok() {
91 Self::debug()
92 } else {
93 Self::default()
95 }
96 }
97
98 pub fn with_logging(mut self) -> Self {
100 self.log_events = true;
101 self
102 }
103
104 pub fn without_logging(mut self) -> Self {
106 self.log_events = false;
107 self
108 }
109}