refactor: adjust log levels and prefixes for server operations

This commit is contained in:
Andrew Phillips
2025-08-10 22:26:23 -03:00
committed by Andrew Phillips (aider)
parent 35ae5776c0
commit 00b34cb3f7

View File

@@ -103,7 +103,7 @@ async fn run_server(
_conn: &mut rusqlite::Connection,
data_dir: PathBuf,
) -> Result<()> {
info!("Starting REST HTTP server on {}", config.address);
debug!("Starting REST HTTP server on {}", config.address);
// Create a new database connection for the server
// Note: This is a simplified approach. In production, you'd want a connection pool
@@ -141,7 +141,7 @@ async fn run_server(
config.address.parse()?
};
info!("Server listening on {}", addr);
info!("SERVER: HTTP server listening on {}", addr);
let listener = tokio::net::TcpListener::bind(addr).await?;
axum::serve(
@@ -170,7 +170,7 @@ async fn handle_status(
headers: HeaderMap,
ConnectInfo(addr): ConnectInfo<SocketAddr>,
) -> Result<Json<ApiResponse<StatusInfo>>, StatusCode> {
debug!("GET /status from {}", addr);
info!("SERVER: GET /status from {}", addr);
if !check_auth(&headers, &state.password) {
warn!("Unauthorized request from {}", addr);
return Err(StatusCode::UNAUTHORIZED);
@@ -208,7 +208,7 @@ async fn handle_list_items(
headers: HeaderMap,
ConnectInfo(addr): ConnectInfo<SocketAddr>,
) -> Result<Json<ApiResponse<Vec<ItemInfo>>>, StatusCode> {
debug!("GET /item/ from {} with params: {:?}", addr, params);
info!("SERVER: GET /item/ from {} with params: {:?}", addr, params);
if !check_auth(&headers, &state.password) {
warn!("Unauthorized request to /item/ from {}", addr);
return Err(StatusCode::UNAUTHORIZED);
@@ -286,7 +286,7 @@ async fn handle_get_item(
headers: HeaderMap,
ConnectInfo(addr): ConnectInfo<SocketAddr>,
) -> Result<Json<ApiResponse<ItemInfo>>, StatusCode> {
debug!("GET /item/{} from {} with params: {:?}", item_id, addr, params);
info!("SERVER: GET /item/{} from {} with params: {:?}", item_id, addr, params);
if !check_auth(&headers, &state.password) {
warn!("Unauthorized request to /item/{} from {}", item_id, addr);
return Err(StatusCode::UNAUTHORIZED);
@@ -358,7 +358,7 @@ async fn handle_put_item(
headers: HeaderMap,
ConnectInfo(addr): ConnectInfo<SocketAddr>,
) -> Result<Json<ApiResponse<ItemInfo>>, StatusCode> {
debug!("PUT /item/ from {}", addr);
info!("SERVER: PUT /item/ from {}", addr);
if !check_auth(&headers, &state.password) {
warn!("Unauthorized request to PUT /item/ from {}", addr);
return Err(StatusCode::UNAUTHORIZED);
@@ -383,7 +383,7 @@ async fn handle_delete_item(
headers: HeaderMap,
ConnectInfo(addr): ConnectInfo<SocketAddr>,
) -> Result<Json<ApiResponse<()>>, StatusCode> {
debug!("DELETE /item/{} from {}", item_id, addr);
info!("SERVER: DELETE /item/{} from {}", item_id, addr);
if !check_auth(&headers, &state.password) {
warn!("Unauthorized request to DELETE /item/{} from {}", item_id, addr);
return Err(StatusCode::UNAUTHORIZED);
@@ -421,7 +421,7 @@ async fn handle_get_content_latest(
headers: HeaderMap,
ConnectInfo(addr): ConnectInfo<SocketAddr>,
) -> Result<Json<ApiResponse<String>>, StatusCode> {
debug!("GET /content from {} with params: {:?}", addr, params);
info!("SERVER: GET /content from {} with params: {:?}", addr, params);
if !check_auth(&headers, &state.password) {
warn!("Unauthorized request to /content from {}", addr);
return Err(StatusCode::UNAUTHORIZED);
@@ -474,7 +474,7 @@ async fn handle_get_content(
headers: HeaderMap,
ConnectInfo(addr): ConnectInfo<SocketAddr>,
) -> Result<Json<ApiResponse<String>>, StatusCode> {
debug!("GET /content/{} from {}", item_id, addr);
info!("SERVER: GET /content/{} from {}", item_id, addr);
if !check_auth(&headers, &state.password) {
warn!("Unauthorized request to /content/{} from {}", item_id, addr);
return Err(StatusCode::UNAUTHORIZED);