From 0ccbd86e3013dfd44f316be3d724181264ce606e Mon Sep 17 00:00:00 2001 From: knylbyte <40831653+knylbyte@users.noreply.github.com> Date: Wed, 17 Dec 2025 21:13:56 +0100 Subject: [PATCH] feat: enhenced session logging -> print user from pool --- backend/src/api/api_utils.rs | 39 +++++++++++++++---- .../src/api/model/provider_lineup_manager.rs | 16 ++++---- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/backend/src/api/api_utils.rs b/backend/src/api/api_utils.rs index bb26d967c..02e148f9c 100644 --- a/backend/src/api/api_utils.rs +++ b/backend/src/api/api_utils.rs @@ -365,26 +365,51 @@ async fn resolve_streaming_strategy( let stream = create_provider_connections_exhausted_stream(&app_state.app_config, &[]); ProviderStreamState::Custom(stream) } - ProviderAllocation::Available(ref provider) - | ProviderAllocation::GracePeriod(ref provider) => { + ProviderAllocation::Available(ref provider_cfg) + | ProviderAllocation::GracePeriod(ref provider_cfg) => { + let allocation_kind = match allocation { + ProviderAllocation::Available(_) => "available", + ProviderAllocation::GracePeriod(_) => "grace_period", + ProviderAllocation::Exhausted => "exhausted", + }; + // force_stream_provider means we keep the url and the provider. // If force_stream_provider or the input is the same as the config we don't need to get new url - let (provider, url) = if force_provider.is_some() || provider.id == input.id { + let (selected_provider_name, url) = if force_provider.is_some() || provider_cfg.id == input.id { (input.name.clone(), stream_url.to_string()) } else { ( - provider.name.clone(), - get_stream_alternative_url(stream_url, input, provider), + provider_cfg.name.clone(), + get_stream_alternative_url(stream_url, input, provider_cfg), ) }; + if let Some(user_info) = provider_cfg.get_user_info() { + debug_if_enabled!( + "provider session: input={} provider_cfg={} user={} allocation={} stream_url={}", + sanitize_sensitive_info(&input.name), + sanitize_sensitive_info(&provider_cfg.name), + sanitize_sensitive_info(&user_info.username), + allocation_kind, + sanitize_sensitive_info(&url) + ); + } else { + debug_if_enabled!( + "provider session: input={} provider_cfg={} user=? allocation={} stream_url={}", + sanitize_sensitive_info(&input.name), + sanitize_sensitive_info(&provider_cfg.name), + allocation_kind, + sanitize_sensitive_info(&url) + ); + } + match allocation { ProviderAllocation::Exhausted => { let stream = create_provider_connections_exhausted_stream(&app_state.app_config, &[]); ProviderStreamState::Custom(stream) }, - ProviderAllocation::Available(_) => ProviderStreamState::Available(Some(provider), url), - ProviderAllocation::GracePeriod(_) => ProviderStreamState::GracePeriod(Some(provider), url), + ProviderAllocation::Available(_) => ProviderStreamState::Available(Some(selected_provider_name), url), + ProviderAllocation::GracePeriod(_) => ProviderStreamState::GracePeriod(Some(selected_provider_name), url), } } } diff --git a/backend/src/api/model/provider_lineup_manager.rs b/backend/src/api/model/provider_lineup_manager.rs index e29093d2a..6a26733bf 100644 --- a/backend/src/api/model/provider_lineup_manager.rs +++ b/backend/src/api/model/provider_lineup_manager.rs @@ -656,13 +656,15 @@ impl ProviderLineupManager { fn log_allocation(allocation: &ProviderAllocation) { - if log_enabled!(log::Level::Debug) { - match allocation { - ProviderAllocation::Exhausted => {} - ProviderAllocation::Available(ref cfg) | - ProviderAllocation::GracePeriod(ref cfg) => { - debug!("Using provider {}", cfg.name); - } + match allocation { + ProviderAllocation::Exhausted => {} + ProviderAllocation::Available(ref cfg) | ProviderAllocation::GracePeriod(ref cfg) => { + debug_if_enabled!( + "Using provider {} (pool user: {})", + sanitize_sensitive_info(&cfg.name), + cfg.get_user_info() + .map_or_else(|| "?".to_string(), |ui| sanitize_sensitive_info(&ui.username).to_string()) + ); } } }