Skip to content

Commit

Permalink
changed all the println to use log::info | debug (#46)
Browse files Browse the repository at this point in the history
* changed all the println to use log::info | debug

* fix cargo fmt

---------

Co-authored-by: Helio Frota <[email protected]>
  • Loading branch information
NoodleSamaChan and helio-frota authored Mar 11, 2024
1 parent bef5ced commit e2d6cc8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 28 deletions.
4 changes: 2 additions & 2 deletions backend/api/src/system/advisory/csaf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl AdvisoryContext {
/*
for purl in resolve_purls(&csaf, r) {
let package = Purl::from(purl.clone());
println!("{}", package.to_string());
log::debug!("{}", package.to_string());
//advisory_vulnerability
//.ingest_affected_package_range(package, Transactional::None)
//.await?;
Expand Down Expand Up @@ -117,7 +117,7 @@ mod tests {
.vulnerability_assertions(Transactional::None)
.await?;

println!("{:#?}", assertions);
log::info!("{:#?}", assertions);

Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions backend/api/src/system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ impl InnerSystem {
host,
port.into().unwrap_or(5432)
);
println!("bootstrap to {}", url);
debug!("bootstrap to {}", url);
log::info!("bootstrap to {}", url);
log::debug!("bootstrap to {}", url);
let db = Database::connect(url).await?;

let drop_db_result = db
Expand Down
6 changes: 1 addition & 5 deletions backend/api/src/system/sbom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ impl SbomContext {

Ok(related)
} else {
println!("no package");
log::info!("no package");
Ok(vec![])
}
}
Expand Down Expand Up @@ -774,31 +774,27 @@ mod tests {
let sbom_v3 = system
.ingest_sbom("http://sbom.com/test.json", "10", Transactional::None)
.await?;
println!("a");

sbom_v1
.ingest_describes_cpe22(
cpe::uri::Uri::parse("cpe:/a:redhat:quarkus:2.13::el8")?,
Transactional::None,
)
.await?;
println!("b");

sbom_v2
.ingest_describes_cpe22(
cpe::uri::Uri::parse("cpe:/a:redhat:quarkus:2.13::el8")?,
Transactional::None,
)
.await?;
println!("c");

sbom_v3
.ingest_describes_cpe22(
cpe::uri::Uri::parse("cpe:/a:redhat:not-quarkus:2.13::el8")?,
Transactional::None,
)
.await?;
println!("d");

let found = system
.locate_sboms(
Expand Down
32 changes: 16 additions & 16 deletions backend/api/src/system/sbom/spdx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ impl SbomContext {
{
for reference in &described_package.external_reference {
if reference.reference_type == "purl" {
//println!("describes pkg {}", reference.reference_locator);
//log::debug!("describes pkg {}", reference.reference_locator);
sbom.ingest_describes_package(
reference.reference_locator.clone(),
tx,
)
.await?;
} else if reference.reference_type == "cpe22Type" {
//println!("describes cpe22 {}", reference.reference_locator);
//log::debug!("describes cpe22 {}", reference.reference_locator);
if let Ok(cpe) = cpe::uri::Uri::parse(&reference.reference_locator) {
sbom.ingest_describes_cpe22(
cpe,
Expand All @@ -64,7 +64,7 @@ impl SbomContext {
for package_ref in &package_info.external_reference {
if package_ref.reference_type == "purl" {
let package_a = package_ref.reference_locator.clone();
//println!("pkg_a: {}", package_a);
//log::debug!("pkg_a: {}", package_a);

for relationship in sbom_data
.relationships_for_spdx_id(package_identifier)
Expand Down Expand Up @@ -208,7 +208,7 @@ mod tests {
assert_eq!(1, described_cpe222.len());

let described_packages = sbom.describes_packages(Transactional::None).await?;
println!("{:#?}", described_packages);
log::info!("{:#?}", described_packages);

let contains = sbom
.related_packages(
Expand All @@ -218,15 +218,15 @@ mod tests {
)
.await?;

println!("{}", contains.len());
log::info!("{}", contains.len());

assert!(contains.len() > 500);

let query_time = start.elapsed();

println!("parse {}ms", parse_time.as_millis());
println!("ingest {}ms", ingest_time.as_millis());
println!("query {}ms", query_time.as_millis());
log::info!("parse {}ms", parse_time.as_millis());
log::info!("ingest {}ms", ingest_time.as_millis());
log::info!("query {}ms", query_time.as_millis());

Ok(())
}
Expand Down Expand Up @@ -261,7 +261,7 @@ mod tests {
assert_eq!(1, described_cpe222.len());

let described_packages = sbom.describes_packages(Transactional::None).await?;
println!("{:#?}", described_packages);
log::info!("{:#?}", described_packages);

let contains = sbom
.related_packages(
Expand All @@ -277,9 +277,9 @@ mod tests {

let query_time = start.elapsed();

println!("parse {}ms", parse_time.as_millis());
println!("ingest {}ms", ingest_time.as_millis());
println!("query {}ms", query_time.as_millis());
log::info!("parse {}ms", parse_time.as_millis());
log::info!("ingest {}ms", ingest_time.as_millis());
log::info!("query {}ms", query_time.as_millis());

Ok(())
}
Expand Down Expand Up @@ -321,15 +321,15 @@ mod tests {
)
.await?;

println!("{}", contains.len());
log::info!("{}", contains.len());

assert!(contains.len() > 500);

let query_time = start.elapsed();

println!("parse {}ms", parse_time.as_millis());
println!("ingest {}ms", ingest_time.as_millis());
println!("query {}ms", query_time.as_millis());
log::info!("parse {}ms", parse_time.as_millis());
log::info!("ingest {}ms", ingest_time.as_millis());
log::info!("query {}ms", query_time.as_millis());

Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions backend/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ impl Cli {
match self.run_command().await {
Ok(code) => code,
Err(err) => {
eprintln!("Error: {err}");
log::info!("Error: {err}");
for (n, err) in err.chain().skip(1).enumerate() {
if n == 0 {
eprintln!("Caused by:");
log::info!("Caused by:");
}
eprintln!("\t{err}");
log::info!("\t{err}");
}

ExitCode::FAILURE
Expand Down

0 comments on commit e2d6cc8

Please sign in to comment.