From eccceef663b7f483f8c6ae8fc4c627d6fc54e81d Mon Sep 17 00:00:00 2001 From: Bulat Kurbanov Date: Fri, 28 Feb 2025 19:28:59 +0100 Subject: [PATCH] Update logging --- src/main.rs | 2 +- src/subscription_manager.rs | 6 +++++- src/twitch_webhook.rs | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 669f413..f2fc737 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,6 +27,6 @@ async fn main() { ); if let Err(e) = webhook_result { - eprintln!("Error in webhook: {:?}", e); + tracing::error!("Error starting Twitch webhook: {}", e); } } diff --git a/src/subscription_manager.rs b/src/subscription_manager.rs index 11a9330..190cba7 100644 --- a/src/subscription_manager.rs +++ b/src/subscription_manager.rs @@ -14,10 +14,12 @@ impl SubscriptionManager { } pub async fn init(&self) { - println!("SubscriptionManager initialized"); + tracing::debug!("Initializing subscription manager"); } pub async fn subscribe(&self, telegram_user_id: u64, username: String) { + tracing::debug!("Subscribing {} to {}", telegram_user_id, username); + self.subscriptions .write() .await @@ -27,6 +29,8 @@ impl SubscriptionManager { } pub async fn unsubscribe(&self, telegram_user_id: u64, username: String) { + tracing::debug!("Unsubscribing {} from {}", telegram_user_id, username); + self.subscriptions .write() .await diff --git a/src/twitch_webhook.rs b/src/twitch_webhook.rs index 77cfaf4..50b9a95 100644 --- a/src/twitch_webhook.rs +++ b/src/twitch_webhook.rs @@ -130,6 +130,8 @@ pub async fn twitch_eventsub( } use twitch_api::eventsub::{Message as M, Payload as P}; + tracing::info!("Event: {:?}", event); + match event { Event::StreamOnlineV1(P { message: @@ -197,6 +199,8 @@ impl TwitchWebhookServer { } pub async fn subscribe(&self, streamer: String) -> bool { + tracing::info!("Subscribing to {}", streamer); + match eventsub_register( self.app_access_token.clone(), streamer.clone(), @@ -206,7 +210,7 @@ impl TwitchWebhookServer { { Ok(_) => true, Err(err) => { - eprintln!("Error subscribing to {}: {}", streamer, err); + tracing::error!("Failed to subscribe to {}: {:?}", streamer, err); false } }