From e31f9f904a5f5905e912907d988c189ffc8cf313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20H=C3=B6lting?= <87192362+moritz-hoelting@users.noreply.github.com> Date: Sat, 15 Jun 2024 21:46:47 +0200 Subject: [PATCH] add tracing crate for logging --- .gitignore | 1 - Cargo.toml | 1 + src/datapack/function.rs | 4 ++++ src/datapack/mod.rs | 3 +++ src/datapack/namespace.rs | 3 +++ 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 75239f2..8b84bc4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ /dist /target -/Cargo.lock diff --git a/Cargo.toml b/Cargo.toml index 1fd24da..b67476d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,4 +21,5 @@ chksum-md5 = "0.0.0" getset = "0.1.2" serde = { version = "1.0.197", optional = true, features = ["derive"] } serde_json = "1.0.114" +tracing = "0.1.40" zip = { version = "1.1.1", default-features = false, features = ["deflate", "time"], optional = true } diff --git a/src/datapack/function.rs b/src/datapack/function.rs index 923f036..1905995 100644 --- a/src/datapack/function.rs +++ b/src/datapack/function.rs @@ -47,12 +47,16 @@ impl Function { } /// Compile the function into a virtual file. + #[must_use] + #[tracing::instrument(level = "trace", skip_all)] pub fn compile( &self, options: &CompileOptions, global_state: &MutCompilerState, function_state: &FunctionCompilerState, ) -> VFile { + tracing::trace!("Compiling function '{}'", self.name); + let content = self .commands .iter() diff --git a/src/datapack/mod.rs b/src/datapack/mod.rs index 83f140c..d94de5c 100644 --- a/src/datapack/mod.rs +++ b/src/datapack/mod.rs @@ -106,7 +106,10 @@ impl Datapack { /// Compile the pack into a virtual folder. #[must_use] + #[tracing::instrument(level = "debug", skip(self))] pub fn compile(&self, options: &CompileOptions) -> VFolder { + tracing::debug!("Compiling datapack: {:?}", self); + let compiler_state = Mutex::new(CompilerState::default()); let mut root_folder = self.custom_files.clone(); diff --git a/src/datapack/namespace.rs b/src/datapack/namespace.rs index f4b4f0a..4fcea85 100644 --- a/src/datapack/namespace.rs +++ b/src/datapack/namespace.rs @@ -79,7 +79,10 @@ impl Namespace { } /// Compile the namespace into a virtual folder. + #[tracing::instrument(level = "debug", skip_all)] pub fn compile(&self, options: &CompileOptions, state: &MutCompilerState) -> VFolder { + tracing::debug!("Compiling namespace"); + let mut root_folder = VFolder::new(); // Compile functions