Skip to content

Commit 889079d

Browse files
committed
Better Delphi logging
1 parent 367a2ec commit 889079d

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

apps/labrinth/.sqlx/query-a06d0f682b1e576e634b02102ab6bcab9fcba55df818cab6e98721a324659526.json renamed to apps/labrinth/.sqlx/query-900f4266e8926fc0458709081eb2b2249314019825c43f2b391847c782ce97fa.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/labrinth/.sqlx/query-26a43c77d3c1e875889141d209f01763de4c51bd16c100549261b11c5a4142b8.json renamed to apps/labrinth/.sqlx/query-b65094517546487e43b65a76aa38efd9e422151b683d9897a071ee0c4bac1cd4.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/labrinth/src/routes/internal/delphi.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use reqwest::header::{HeaderMap, HeaderValue, USER_AGENT};
66
use serde::Deserialize;
77
use sqlx::PgPool;
88
use tokio::sync::Mutex;
9-
use tracing::{info, warn};
9+
use tracing::info;
1010

1111
use crate::{
1212
auth::check_is_moderator_from_headers,
@@ -72,7 +72,7 @@ struct DelphiReport {
7272
pub url: String,
7373
pub project_id: crate::models::ids::ProjectId,
7474
#[serde(rename = "version_id")]
75-
pub _version_id: crate::models::ids::VersionId,
75+
pub version_id: crate::models::ids::VersionId,
7676
pub file_id: crate::models::ids::FileId,
7777
/// A sequential, monotonically increasing version number for the
7878
/// Delphi version that generated this report.
@@ -128,23 +128,23 @@ pub struct DelphiRunParameters {
128128
}
129129

130130
#[post("ingest", guard = "admin_key_guard")]
131+
#[tracing::instrument(
132+
level = "info",
133+
skip_all,
134+
fields(
135+
%report.url,
136+
%report.file_id,
137+
%report.project_id,
138+
%report.version_id,
139+
)
140+
)]
131141
async fn ingest_report(
132142
pool: web::Data<PgPool>,
133143
redis: web::Data<RedisPool>,
134-
report: web::Bytes,
135-
// web::Json(report): web::Json<DelphiReport>,
144+
web::Json(report): web::Json<DelphiReport>,
136145
) -> Result<(), ApiError> {
137-
info!(
138-
"Json: {}",
139-
serde_json::to_string_pretty(
140-
&serde_json::from_slice::<serde_json::Value>(&report).unwrap()
141-
)
142-
.unwrap()
143-
);
144-
let report = serde_json::from_slice::<DelphiReport>(&report).unwrap();
145-
146146
if report.issues.is_empty() {
147-
info!("No issues found for file {}", report.url);
147+
info!("No issues found for file");
148148
return Ok(());
149149
}
150150

@@ -163,10 +163,9 @@ async fn ingest_report(
163163
.upsert(&mut transaction)
164164
.await?;
165165

166-
warn!(
167-
"Delphi found {} issues in file {}",
168-
report.issues.len(),
169-
report.url
166+
info!(
167+
num_issues = %report.issues.len(),
168+
"Delphi found issues in file",
170169
);
171170

172171
for (issue_type, issue_details) in report.issues {

0 commit comments

Comments
 (0)