A library for ATProtocol identities.

refactor: tracing cleanup

Signed-off-by: Nick Gerakines <nick.gerakines@gmail.com>

Changed files
+15 -12
crates
atproto-xrpcs
atproto-xrpcs-helloworld
src
+4
CLAUDE.md
··· 59 59 60 60 Use tracing for structured logging. 61 61 62 + All calls to `tracing::error`, `tracing::warn`, `tracing::info`, `tracing::debug`, and `tracing::trace` should be fully qualified. 63 + 64 + Do not use the `println!` macro in library code. 65 + 62 66 Async calls should be instrumented using the `.instrument()` that references the `use tracing::Instrument;` trait. 63 67 64 68 ## Module Structure
+2 -2
crates/atproto-xrpcs-helloworld/src/main.rs
··· 196 196 "publicKeyMultibase": public_service_key 197 197 }], 198 198 "service":[{ 199 - "id":"#bsky_appview", 200 - "type":"BskyAppView", 199 + "id":"#helloworld", 200 + "type":"HelloWorldService", 201 201 "serviceEndpoint":format!("https://{external_base}") 202 202 }] 203 203 }
+9 -10
crates/atproto-xrpcs/src/authorization.rs
··· 16 16 use base64::engine::general_purpose; 17 17 use std::convert::Infallible; 18 18 use std::sync::Arc; 19 - use tracing::{debug, error, info}; 20 19 21 20 use crate::errors::AuthorizationError; 22 21 ··· 52 51 let token = match auth_header { 53 52 Some(token) => token.to_string(), 54 53 None => { 55 - debug!("No Authorization header found or Bearer token missing"); 54 + tracing::debug!("No Authorization header found or Bearer token missing"); 56 55 return Ok(None); 57 56 } 58 57 }; ··· 61 60 62 61 match validate_jwt(&token, did_document_storage.0, None).await { 63 62 Ok((header, claims)) => { 64 - debug!("JWT successfully validated"); 63 + tracing::debug!("JWT successfully validated"); 65 64 Ok(Some(Authorization(header, claims, token, true))) 66 65 } 67 66 Err(e) => { 68 - error!(error = ?e, "JWT validation failed"); 67 + tracing::error!(error = ?e, "JWT validation failed"); 69 68 // Return unvalidated authorization so the handler can decide what to do 70 69 let header = Header::default(); 71 70 let claims = Claims::default(); ··· 96 95 let token = match auth_header { 97 96 Some(token) => token.to_string(), 98 97 None => { 99 - info!("No Authorization header found or Bearer token missing"); 98 + tracing::info!("No Authorization header found or Bearer token missing"); 100 99 return Ok(None); 101 100 } 102 101 }; ··· 107 106 match validate_jwt(&token, did_document_storage.0, Some(&identity_resolver)).await { 108 107 Ok((header, claims)) => Ok(Some(ResolvingAuthorization(header, claims, token, true))), 109 108 Err(e) => { 110 - debug!("JWT validation failed with resolving storage: {e:?}"); 109 + tracing::debug!("JWT validation failed with resolving storage: {e:?}"); 111 110 // Return unvalidated authorization so the handler can decide what to do 112 111 let header = Header::default(); 113 112 let claims = Claims::default(); ··· 144 143 .as_ref() 145 144 .ok_or_else(|| AuthorizationError::NoIssuerInClaims)?; 146 145 147 - debug!("JWT issuer: {}", issuer); 146 + tracing::debug!("JWT issuer: {}", issuer); 148 147 149 148 // Try to look up DID document directly first 150 149 let mut did_document = storage.get_document_by_did(issuer).await?; 151 150 152 151 // If not found, try to resolve the subject 153 152 if did_document.is_none() { 154 - debug!( 153 + tracing::debug!( 155 154 "DID document not found for issuer: {}, attempting resolution", 156 155 issuer 157 156 ); ··· 180 179 let did_document = did_document.ok_or_else(|| AuthorizationError::DIDDocumentNotFound { 181 180 issuer: issuer.to_string(), 182 181 })?; 183 - debug!("Found DID document for issuer: {}", issuer); 182 + tracing::debug!("Found DID document for issuer: {}", issuer); 184 183 185 184 // Extract keys from DID document 186 185 let did_keys = did_document.did_keys(); ··· 188 187 return Err(AuthorizationError::NoVerificationKeys.into()); 189 188 } 190 189 191 - debug!("Found {} verification keys in DID document", did_keys.len()); 190 + tracing::debug!("Found {} verification keys in DID document", did_keys.len()); 192 191 193 192 // Try to validate with each key 194 193 for key_multibase in did_keys {