From 2b6e663f5483f39037bc8efe3163d630d6d7782f Mon Sep 17 00:00:00 2001 From: trivernis Date: Sat, 24 Sep 2022 13:38:07 +0200 Subject: [PATCH] Add tracing to some more functions --- src/lib.rs | 2 +- src/scripting/executor.rs | 5 +++++ src/scripting/loader.rs | 1 + src/scripting/script.rs | 4 +++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 72738f5..9f96576 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,7 @@ pub struct TaskExecutor { impl TaskExecutor { /// Sets up user accounts - #[tracing::instrument(level = "debug", skip(self))] + #[tracing::instrument(level = "trace", skip(self))] pub async fn setup_users(&self, users_cfg: UsersConfig) -> AppResult<()> { self.loader .load::()? diff --git a/src/scripting/executor.rs b/src/scripting/executor.rs index e2bfb82..9df6f9a 100644 --- a/src/scripting/executor.rs +++ b/src/scripting/executor.rs @@ -74,6 +74,7 @@ impl NuExecutor { } /// Executes the given script file in a clean nu context. + #[tracing::instrument(level = "trace", skip_all)] pub async fn execute(&mut self) -> AppResult<()> { let mut engine_state = nu_command::create_default_context(); let mut stack = nu_protocol::engine::Stack::new(); @@ -128,6 +129,7 @@ impl NuExecutor { /// Adds variables to the nu engine state /// Note: Calling this function multiple times will override other variables +#[tracing::instrument(level = "trace", skip(state, stack))] fn add_variables_to_state( vars: HashMap, state: &mut EngineState, @@ -152,6 +154,7 @@ fn add_variables_to_state( /// Reads the nu script file and /// returns its root block +#[tracing::instrument(level = "trace", skip(engine_state))] async fn read_script_file( path: &Path, engine_state: &mut EngineState, @@ -172,6 +175,7 @@ async fn read_script_file( } /// Parses a nu script +#[tracing::instrument(level = "trace", skip_all)] fn parse_nu<'a>( engine_state: &'a mut EngineState, script: &[u8], @@ -189,6 +193,7 @@ fn parse_nu<'a>( /// Creates a call nu expression with the given main block declaration ID /// and arguments in the form of record values +#[tracing::instrument(level = "trace")] fn create_call(decl_id: DeclId, args: Vec) -> Block { let args = args .into_iter() diff --git a/src/scripting/loader.rs b/src/scripting/loader.rs index 73f939e..6c9a5ae 100644 --- a/src/scripting/loader.rs +++ b/src/scripting/loader.rs @@ -18,6 +18,7 @@ impl ScriptLoader { } /// Loads the given script file + #[tracing::instrument(level = "trace", skip_all)] pub fn load(&self) -> AppResult> { let script_path = self.base_dir.join(S::get_name()); diff --git a/src/scripting/script.rs b/src/scripting/script.rs index 4ef8ade..026e5af 100644 --- a/src/scripting/script.rs +++ b/src/scripting/script.rs @@ -1,3 +1,4 @@ +use core::fmt; use std::{marker::PhantomData, path::PathBuf}; use serde::Serialize; @@ -13,7 +14,7 @@ use super::{ /// A trait implemented for a given nu script type to /// associate arguments pub trait Script { - type Args: ScriptArgs; + type Args: ScriptArgs + fmt::Debug; /// Returns the (expected) name of the script file /// This function is used by the loader to load the associated file @@ -53,6 +54,7 @@ impl NuScript { } /// Executes the script with the given args + #[tracing::instrument(level = "trace", skip(self))] pub async fn execute(&self, args: S::Args) -> AppResult<()> { NuExecutor::new(&self.path) .add_args(args.get_args())