Skip to content

Commit b8078f9

Browse files
committed
Flush stderr logs
1 parent 0e85bc1 commit b8078f9

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

backend/src/bin/seed.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
use std::{error::Error, fs};
1+
use std::{
2+
error::Error,
3+
fs,
4+
io::{self, Write},
5+
};
26

37
use backend::{
48
create_connection,
@@ -115,6 +119,7 @@ async fn insert_challenges() -> Result<(), Box<dyn Error + Send + Sync>> {
115119
for error in &parse_errors {
116120
eprintln!(" {error}");
117121
}
122+
io::stderr().flush().unwrap_or_default();
118123
if challenges_to_process.is_empty() {
119124
return Err("No valid challenges to insert".into());
120125
}
@@ -198,6 +203,7 @@ async fn insert_rewards() -> Result<(), Box<dyn Error + Send + Sync>> {
198203
for error in &parse_errors {
199204
eprintln!(" {error}");
200205
}
206+
io::stderr().flush().unwrap_or_default();
201207
if rewards_to_process.is_empty() {
202208
return Err("No valid rewards to insert".into());
203209
}

backend/src/handlers/completion.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::io::{self, Write};
2+
13
use crate::services::traits::{ChallengeServiceTrait, CompletionServiceTrait};
24
use crate::{AppState, AuthClaims};
35
use axum::{Extension, Json, extract::State, http::StatusCode};
@@ -78,6 +80,7 @@ pub async fn create_completion(
7880
.await
7981
.map_err(|e| {
8082
eprintln!("Failed to get challenge: {e}");
83+
io::stderr().flush().unwrap_or_default();
8184
StatusCode::INTERNAL_SERVER_ERROR
8285
})?;
8386

@@ -117,6 +120,7 @@ pub async fn create_completion(
117120
.await
118121
.map_err(|e| {
119122
eprintln!("Failed to check completion existence: {e}");
123+
io::stderr().flush().unwrap_or_default();
120124
StatusCode::INTERNAL_SERVER_ERROR
121125
})?;
122126

@@ -166,6 +170,7 @@ pub async fn create_completion(
166170
.await
167171
.map_err(|e| {
168172
eprintln!("Failed to upload image: {e}");
173+
io::stderr().flush().unwrap_or_default();
169174
StatusCode::INTERNAL_SERVER_ERROR
170175
})?;
171176
}
@@ -186,6 +191,7 @@ pub async fn create_completion(
186191
.await
187192
.map_err(|e| {
188193
eprintln!("Failed to create completion: {e}");
194+
io::stderr().flush().unwrap_or_default();
189195
StatusCode::INTERNAL_SERVER_ERROR
190196
})?;
191197

backend/src/services/transaction.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use std::collections::HashMap;
1+
use std::{
2+
collections::HashMap,
3+
io::{self, Write},
4+
};
25

36
use crate::entities::{prelude::*, reward, transaction, user};
47
use chrono::Utc;
@@ -33,6 +36,7 @@ impl TransactionService {
3336
"Failed to get total purchased for Carnegie Cup Contribution: {}",
3437
f
3538
);
39+
io::stderr().flush().unwrap_or_default();
3640
})?;
3741

3842
Ok(total.unwrap_or(0))

0 commit comments

Comments
 (0)