Add tracing to some more functions

integration-not-installation
trivernis 2 years ago
parent 52b39b1598
commit 2b6e663f54
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -13,7 +13,7 @@ pub struct TaskExecutor {
impl TaskExecutor { impl TaskExecutor {
/// Sets up user accounts /// 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<()> { pub async fn setup_users(&self, users_cfg: UsersConfig) -> AppResult<()> {
self.loader self.loader
.load::<SetupUsersScript>()? .load::<SetupUsersScript>()?

@ -74,6 +74,7 @@ impl NuExecutor {
} }
/// Executes the given script file in a clean nu context. /// Executes the given script file in a clean nu context.
#[tracing::instrument(level = "trace", skip_all)]
pub async fn execute(&mut self) -> AppResult<()> { pub async fn execute(&mut self) -> AppResult<()> {
let mut engine_state = nu_command::create_default_context(); let mut engine_state = nu_command::create_default_context();
let mut stack = nu_protocol::engine::Stack::new(); let mut stack = nu_protocol::engine::Stack::new();
@ -128,6 +129,7 @@ impl NuExecutor {
/// Adds variables to the nu engine state /// Adds variables to the nu engine state
/// Note: Calling this function multiple times will override other variables /// Note: Calling this function multiple times will override other variables
#[tracing::instrument(level = "trace", skip(state, stack))]
fn add_variables_to_state( fn add_variables_to_state(
vars: HashMap<String, Value>, vars: HashMap<String, Value>,
state: &mut EngineState, state: &mut EngineState,
@ -152,6 +154,7 @@ fn add_variables_to_state(
/// Reads the nu script file and /// Reads the nu script file and
/// returns its root block /// returns its root block
#[tracing::instrument(level = "trace", skip(engine_state))]
async fn read_script_file( async fn read_script_file(
path: &Path, path: &Path,
engine_state: &mut EngineState, engine_state: &mut EngineState,
@ -172,6 +175,7 @@ async fn read_script_file(
} }
/// Parses a nu script /// Parses a nu script
#[tracing::instrument(level = "trace", skip_all)]
fn parse_nu<'a>( fn parse_nu<'a>(
engine_state: &'a mut EngineState, engine_state: &'a mut EngineState,
script: &[u8], script: &[u8],
@ -189,6 +193,7 @@ fn parse_nu<'a>(
/// Creates a call nu expression with the given main block declaration ID /// Creates a call nu expression with the given main block declaration ID
/// and arguments in the form of record values /// and arguments in the form of record values
#[tracing::instrument(level = "trace")]
fn create_call(decl_id: DeclId, args: Vec<RecordValue>) -> Block { fn create_call(decl_id: DeclId, args: Vec<RecordValue>) -> Block {
let args = args let args = args
.into_iter() .into_iter()

@ -18,6 +18,7 @@ impl ScriptLoader {
} }
/// Loads the given script file /// Loads the given script file
#[tracing::instrument(level = "trace", skip_all)]
pub fn load<S: Script>(&self) -> AppResult<NuScript<S>> { pub fn load<S: Script>(&self) -> AppResult<NuScript<S>> {
let script_path = self.base_dir.join(S::get_name()); let script_path = self.base_dir.join(S::get_name());

@ -1,3 +1,4 @@
use core::fmt;
use std::{marker::PhantomData, path::PathBuf}; use std::{marker::PhantomData, path::PathBuf};
use serde::Serialize; use serde::Serialize;
@ -13,7 +14,7 @@ use super::{
/// A trait implemented for a given nu script type to /// A trait implemented for a given nu script type to
/// associate arguments /// associate arguments
pub trait Script { pub trait Script {
type Args: ScriptArgs; type Args: ScriptArgs + fmt::Debug;
/// Returns the (expected) name of the script file /// Returns the (expected) name of the script file
/// This function is used by the loader to load the associated file /// This function is used by the loader to load the associated file
@ -53,6 +54,7 @@ impl<S: Script> NuScript<S> {
} }
/// Executes the script with the given args /// Executes the script with the given args
#[tracing::instrument(level = "trace", skip(self))]
pub async fn execute(&self, args: S::Args) -> AppResult<()> { pub async fn execute(&self, args: S::Args) -> AppResult<()> {
NuExecutor::new(&self.path) NuExecutor::new(&self.path)
.add_args(args.get_args()) .add_args(args.get_args())

Loading…
Cancel
Save