Skip to content

Commit

Permalink
refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
FroVolod committed Sep 24, 2024
1 parent 6d08a16 commit 6e4d055
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions cargo-near/src/commands/new/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ impl NewContext {
scope: &<New as interactive_clap::ToInteractiveClapContextScope>::InteractiveClapContextScope,
) -> color_eyre::eyre::Result<Self> {
tracing::Span::current().pb_set_message(&format!("'{}' ...", scope.project_dir));
tracing::info!(target: "near_teach_me", "'{}' ...", scope.project_dir);

let project_dir: &std::path::Path = scope.project_dir.as_ref();

if project_dir.exists() {
Expand Down Expand Up @@ -81,6 +83,7 @@ impl NewContext {

#[tracing::instrument(target = "tracing_instrument", name = "Sending a tracking request ...")]
fn track_request() {
tracing::Span::current();
let _detached_thread_handle = std::thread::Builder::new()
.spawn(mixpanel_tracking::track_usage)
.unwrap();
Expand All @@ -93,7 +96,7 @@ fn track_request() {
)]
fn execute_git_commands(project_dir: &std::path::Path) -> near_cli_rs::CliResult {
tracing::Span::current().pb_set_message("`git` commands ...");
tracing::info!(target: "near_teach_me", "`git init`");
tracing::info!(target: "near_teach_me", parent: &tracing::Span::none(), "Execution command: `git init`");
let status = std::process::Command::new("git")
.arg("init")
.current_dir(project_dir)
Expand All @@ -106,7 +109,7 @@ fn execute_git_commands(project_dir: &std::path::Path) -> near_cli_rs::CliResult
));
}

tracing::info!(target: "near_teach_me", "`cargo update`");
tracing::info!(target: "near_teach_me", parent: &tracing::Span::none(), "Execution command: `cargo update`");
let child = std::process::Command::new("cargo")
.arg("update")
.current_dir(project_dir)
Expand All @@ -121,7 +124,7 @@ fn execute_git_commands(project_dir: &std::path::Path) -> near_cli_rs::CliResult
));
}

tracing::info!(target: "near_teach_me", "`git add -A`");
tracing::info!(target: "near_teach_me", parent: &tracing::Span::none(), "Execution command: `git add -A`");
let status = std::process::Command::new("git")
.arg("add")
.arg("-A")
Expand All @@ -135,7 +138,7 @@ fn execute_git_commands(project_dir: &std::path::Path) -> near_cli_rs::CliResult
));
}

tracing::info!(target: "near_teach_me", "`git commit -m init`");
tracing::info!(target: "near_teach_me", parent: &tracing::Span::none(), "Execution command: `git commit -m init`");
let status = std::process::Command::new("git")
.arg("commit")
.arg("-m")
Expand Down
2 changes: 1 addition & 1 deletion cargo-near/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn main() -> CliResult {
.add_directive(tracing::Level::WARN.into())
.add_directive("near_teach_me=info".parse()?)
.add_directive("near_cli_rs=info".parse()?)
.add_directive("cargo_near=info".parse()?);
.add_directive("tracing_instrument=info".parse()?);
tracing_subscriber::registry()
.with(
tracing_subscriber::fmt::layer()
Expand Down

0 comments on commit 6e4d055

Please sign in to comment.