commit cd0e3788c3b8a50081b9c3d462f26bf9edc2d042
parent cd049f485f188ba3f87896e04e71bf4dde2599aa
Author: Silas Brack <silasbrack@gmail.com>
Date: Sat, 25 Apr 2026 17:53:00 +0200
debug: use eprintln for logging
Diffstat:
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/trailbase.rs b/src/trailbase.rs
@@ -36,7 +36,7 @@ pub fn extract_user_id_from_token(auth_token: &str) -> Option<String> {
// JWT format: header.payload.signature
let parts: Vec<&str> = auth_token.split('.').collect();
if parts.len() != 3 {
- tracing::warn!("JWT has {} parts, expected 3", parts.len());
+ eprintln!("JWT has {} parts, expected 3", parts.len());
return None;
}
@@ -44,13 +44,13 @@ pub fn extract_user_id_from_token(auth_token: &str) -> Option<String> {
let payload = base64_decode_url_safe(parts[1])?;
let payload_str = String::from_utf8(payload).ok()?;
- tracing::debug!("JWT payload: {}", payload_str);
+ eprintln!("JWT payload: {}", payload_str);
// Parse as JSON and extract "sub" claim
let json: serde_json::Value = serde_json::from_str(&payload_str).ok()?;
let sub = json.get("sub").and_then(|v| v.as_str()).map(|s| s.to_string());
- tracing::info!("Extracted sub from JWT: {:?}", sub);
+ eprintln!("Extracted sub from JWT: {:?}", sub);
sub
}
@@ -314,7 +314,7 @@ pub async fn create_comment(client: &Client, comment: CreateComment) -> Result<C
let user_id = extract_user_id_from_token(&tokens.auth_token)
.ok_or_else(|| ClientError::Auth("Invalid token".to_string()))?;
- tracing::info!("Creating comment with user_id: {}", user_id);
+ eprintln!("Creating comment with user_id: {}", user_id);
let comment_with_user = CreateCommentWithUser {
story_id: comment.story_id,
@@ -327,11 +327,11 @@ pub async fn create_comment(client: &Client, comment: CreateComment) -> Result<C
let id_str = match client.records("comment").create(&comment_with_user).await {
Ok(id) => {
- tracing::info!("Comment created with id: {}", id);
+ eprintln!("Comment created with id: {}", id);
id
}
Err(e) => {
- tracing::error!("Failed to create comment: {:?}", e);
+ eprintln!("Failed to create comment: {:?}", e);
return Err(e.into());
}
};
@@ -412,7 +412,7 @@ pub async fn vote(client: &Client, target_type: i64, target_id: i64) -> Result<(
let user_id = extract_user_id_from_token(&tokens.auth_token)
.ok_or_else(|| ClientError::Auth("Invalid token".to_string()))?;
- tracing::info!("Creating vote with user_id: {}", user_id);
+ eprintln!("Creating vote with user_id: {}", user_id);
let vote_data = CreateVote {
user_id,
@@ -422,11 +422,11 @@ pub async fn vote(client: &Client, target_type: i64, target_id: i64) -> Result<(
match client.records("vote").create(&vote_data).await {
Ok(id) => {
- tracing::info!("Vote created with id: {}", id);
+ eprintln!("Vote created with id: {}", id);
Ok(())
}
Err(e) => {
- tracing::error!("Failed to create vote: {:?}", e);
+ eprintln!("Failed to create vote: {:?}", e);
Err(e.into())
}
}