add tracing crate for logging

This commit is contained in:
Moritz Hölting 2024-06-15 21:46:47 +02:00
parent cef1dab727
commit e31f9f904a
5 changed files with 11 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,3 +1,2 @@
/dist /dist
/target /target
/Cargo.lock

View File

@ -21,4 +21,5 @@ chksum-md5 = "0.0.0"
getset = "0.1.2" getset = "0.1.2"
serde = { version = "1.0.197", optional = true, features = ["derive"] } serde = { version = "1.0.197", optional = true, features = ["derive"] }
serde_json = "1.0.114" serde_json = "1.0.114"
tracing = "0.1.40"
zip = { version = "1.1.1", default-features = false, features = ["deflate", "time"], optional = true } zip = { version = "1.1.1", default-features = false, features = ["deflate", "time"], optional = true }

View File

@ -47,12 +47,16 @@ impl Function {
} }
/// Compile the function into a virtual file. /// Compile the function into a virtual file.
#[must_use]
#[tracing::instrument(level = "trace", skip_all)]
pub fn compile( pub fn compile(
&self, &self,
options: &CompileOptions, options: &CompileOptions,
global_state: &MutCompilerState, global_state: &MutCompilerState,
function_state: &FunctionCompilerState, function_state: &FunctionCompilerState,
) -> VFile { ) -> VFile {
tracing::trace!("Compiling function '{}'", self.name);
let content = self let content = self
.commands .commands
.iter() .iter()

View File

@ -106,7 +106,10 @@ impl Datapack {
/// Compile the pack into a virtual folder. /// Compile the pack into a virtual folder.
#[must_use] #[must_use]
#[tracing::instrument(level = "debug", skip(self))]
pub fn compile(&self, options: &CompileOptions) -> VFolder { pub fn compile(&self, options: &CompileOptions) -> VFolder {
tracing::debug!("Compiling datapack: {:?}", self);
let compiler_state = Mutex::new(CompilerState::default()); let compiler_state = Mutex::new(CompilerState::default());
let mut root_folder = self.custom_files.clone(); let mut root_folder = self.custom_files.clone();

View File

@ -79,7 +79,10 @@ impl Namespace {
} }
/// Compile the namespace into a virtual folder. /// Compile the namespace into a virtual folder.
#[tracing::instrument(level = "debug", skip_all)]
pub fn compile(&self, options: &CompileOptions, state: &MutCompilerState) -> VFolder { pub fn compile(&self, options: &CompileOptions, state: &MutCompilerState) -> VFolder {
tracing::debug!("Compiling namespace");
let mut root_folder = VFolder::new(); let mut root_folder = VFolder::new();
// Compile functions // Compile functions