Skip to content

Commit

Permalink
updated logger to tracing (#2380)
Browse files Browse the repository at this point in the history
Signed-off-by: Ketan Umare <[email protected]>
Co-authored-by: Ketan Umare <[email protected]>
  • Loading branch information
kumare3 and kumare3 authored Apr 25, 2024
1 parent d34ce56 commit 0027fe1
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 151 deletions.
206 changes: 76 additions & 130 deletions rust/flyrs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions rust/flyrs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ object_store = "0.9.1"
url = "2.5.0"
flate2 = "1.0.28"
tar = "0.4.40"
log = "0.4.21"
log-derive = "0.4.1"
env_logger = "0.11.3"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
4 changes: 1 addition & 3 deletions rust/flyrs/src/distribution.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use flate2::read::GzDecoder;
use log_derive::{logfn, logfn_inputs};
use object_store;
use object_store::{ObjectStore, parse_url};
use object_store::path::Path;
use tar::Archive;
use url::Url;

#[logfn_inputs(Info, fmt = "Downloading distribution from {} to {}")]
#[logfn(ok = "INFO", err = "ERROR")]
#[tracing::instrument(err)]
pub async fn download_unarchive_distribution(src: &Url, dst: &String) -> Result<(), Box<dyn std::error::Error>> {
// Uses the object_store crate to download the distribution from the source to the destination path and untar and unzip it
// The source is a URL to the distribution
Expand Down
12 changes: 4 additions & 8 deletions rust/flyrs/src/executor.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use std::fmt::{Display, Formatter};

use clap::Parser;
use log::{debug, info, log_enabled};
use log::Level::Debug;
use log_derive::{logfn, logfn_inputs};
use pyo3::prelude::*;
use tracing::{debug, info, Level};

use distribution::download_unarchive_distribution;

Expand Down Expand Up @@ -58,7 +56,7 @@ impl Display for ExecutorArgs {
// ):

fn debug_python_setup(py: Python) {
if log_enabled!(Debug) {
if tracing::enabled!(tracing::Level::DEBUG) {
let sys = PyModule::import_bound(py, "sys").unwrap();
let path = sys.getattr("path").unwrap();
let version = sys.getattr("version").unwrap();
Expand All @@ -70,8 +68,7 @@ fn debug_python_setup(py: Python) {
}
}

#[logfn_inputs(Info, fmt = "Invoking task with {}")]
#[logfn(ok = "INFO", err = "ERROR")]
#[tracing::instrument(err)]
pub async fn execute_task(args: &ExecutorArgs) -> Result<(), Box<dyn std::error::Error>>{
pyo3::prepare_freethreaded_python();
let _ = Python::with_gil(|py| -> Result<(), Box<dyn std::error::Error>> {
Expand Down Expand Up @@ -111,8 +108,7 @@ pub async fn execute_task(args: &ExecutorArgs) -> Result<(), Box<dyn std::error:

}

#[logfn_inputs(Info, fmt = "Executor invoked with args{}")]
#[logfn(ok = "INFO", err = "ERROR")]
#[tracing::instrument(level = Level::DEBUG, err)]
pub async fn run(executor_args: &ExecutorArgs) -> Result<(), Box<dyn std::error::Error>> {
if executor_args.dynamic_addl_distro.is_some() {
info!("Found Dynamic distro {:?}", executor_args.dynamic_addl_distro);
Expand Down
Loading

0 comments on commit 0027fe1

Please sign in to comment.