improve logging

This commit is contained in:
Ruben Fiszel
2022-07-28 02:31:52 +02:00
parent c2c83608c8
commit 099caf540d
6 changed files with 14 additions and 10 deletions
-3
View File
@@ -64,10 +64,7 @@ pub async fn audit_log<'c>(
let p_json: serde_json::Value = serde_json::to_value(&parameters).unwrap();
tracing::info!(
username = username,
kind = "audit",
operation = operation,
workspace = w_id,
action_kind = ?action_kind,
resource = resource,
parameters = %p_json
+1 -1
View File
@@ -62,7 +62,7 @@ impl IntoResponse for Error {
Self::SqlErr(_) | Self::BadRequest(_) => StatusCode::BAD_REQUEST,
_ => StatusCode::INTERNAL_SERVER_ERROR,
};
tracing::error!(status = %status, error = %e, kind = "error");
tracing::error!(error = e.to_string());
Response::builder()
.header("Content-Type", "text/plain")
.status(status)
+4 -3
View File
@@ -20,8 +20,8 @@ impl<B> OnResponse<B> for MyOnResponse {
) {
tracing::info!(
latency = %latency.as_millis(),
status = ?response.status(),
"finished processed request")
status = response.status().as_u16(),
"response")
}
}
@@ -34,8 +34,9 @@ impl<B> MakeSpan<B> for MyMakeSpan {
"request",
method = %request.method(),
uri = %request.uri(),
version = ?request.version(),
username = field::Empty,
workspace_id = field::Empty,
email = field::Empty,
)
}
}
+7 -1
View File
@@ -293,9 +293,15 @@ where
};
if let Some(token) = token_o {
if let Ok(Extension(cache)) = Extension::<Arc<AuthCache>>::from_request(req).await {
if let Some(authed) = cache.get_authed(workspace_id, &token).await {
if let Some(authed) = cache.get_authed(workspace_id.clone(), &token).await {
req.extensions_mut().insert(authed.clone());
Span::current().record("username", &authed.username.as_str());
if let Some(email) = authed.email.clone() {
Span::current().record("email", &email.as_str());
}
if let Some(workspace_id) = workspace_id {
Span::current().record("workspace_id", &workspace_id);
}
return Ok(authed);
}
}
+1 -1
View File
@@ -149,7 +149,7 @@ pub async fn update_flow_status_after_job_completion(
.fetch_one(&mut tx)
.await?;
tracing::info!("UPDATE: {:?}", new_status);
tracing::debug!("UPDATE: {:?}", new_status);
let flow_job = get_queued_job(flow, w_id, &mut tx)
.await?
+1 -1
View File
@@ -346,7 +346,7 @@ async fn create_workspace(
"workspaces.create",
ActionKind::Create,
&nw.id,
Some(&authed.email.unwrap()),
Some(nw.name.as_str()),
None,
)
.await?;