devalang_core/core/debugger/
store.rs1use crate::core::debugger::Debugger;
2use devalang_types::{FunctionTable, VariableTable};
3use std::fs::create_dir_all;
4
5pub fn write_variables_log_file(output_dir: &str, file_name: &str, variables: VariableTable) {
6 let debugger = Debugger::new();
7 let mut content = String::new();
8
9 let log_directory = format!("{}/logs", output_dir);
10 create_dir_all(&log_directory).expect("Failed to create log directory");
11
12 for (var_name, var_data) in variables.variables {
13 content.push_str(&format!("{:?} = {:?}\n", var_name, var_data));
14 }
15
16 content.push('\n');
17
18 debugger.write_log_file(&log_directory, file_name, &content);
19}
20
21pub fn write_function_log_file(output_dir: &str, file_name: &str, functions: FunctionTable) {
22 let debugger = Debugger::new();
23 let mut content = String::new();
24
25 let log_directory = format!("{}/logs", output_dir);
26 create_dir_all(&log_directory).expect("Failed to create log directory");
27
28 for (_index, function) in functions.functions {
29 content.push_str(&format!(
30 "'{}' = [{:?}] => {:?}\n",
31 function.name, function.parameters, function.body
32 ));
33 }
34
35 content.push('\n');
36
37 debugger.write_log_file(&log_directory, file_name, &content);
38}