devalang_core/core/debugger/
store.rs

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