From 62d9f74a39a08029ff3dcb8673b2749c94bb3cb7 Mon Sep 17 00:00:00 2001 From: Erica Z Date: Thu, 7 Nov 2024 11:41:41 +0100 Subject: [PATCH] Revert "don't print auth token on mpv logs" This reverts commit e52adda2edb0776e899238c64bda852ca7246136. guilty --- src/subsonic.rs | 6 ------ src/ui/window.rs | 19 ++++++------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/subsonic.rs b/src/subsonic.rs index 6f6e8a0..82d0927 100644 --- a/src/subsonic.rs +++ b/src/subsonic.rs @@ -52,7 +52,6 @@ impl From for Error { pub struct Client { client: reqwest::Client, base_url: reqwest::Url, - token: String, } fn get_random_salt(length: usize) -> String { @@ -104,14 +103,9 @@ impl Client { .user_agent(crate::USER_AGENT) .build()?, base_url, - token: token.to_string(), }) } - pub fn strip_token(&self, string: &str) -> String { - string.replace(&self.token, "[authentication token]") - } - async fn send( &self, request: reqwest::RequestBuilder, diff --git a/src/ui/window.rs b/src/ui/window.rs index 85d8355..b65593c 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -520,29 +520,22 @@ mod imp { fn on_log_message(&self, event: crate::mpv::event::LogMessageEvent) { let span = span!(Level::DEBUG, "mpv_log", prefix = event.prefix); let _guard = span.enter(); - - let event_text = event.text.trim_end_matches("\n"); // trim training newline - let event_text = match self.api.borrow().as_ref() { - None => event_text.to_string(), - Some(api) => api.strip_token(event_text), // hide auth token if printing url - }; - match event.log_level { // level has to be 'static so this sux l if l <= 20 => { - event!(target: "mpv_event", Level::ERROR, "{}", event_text) + event!(target: "mpv_event", Level::ERROR, "{}", event.text.trim()) } l if l <= 30 => { - event!(target: "mpv_event", Level::WARN, "{}", event_text) + event!(target: "mpv_event", Level::WARN, "{}", event.text.trim()) } l if l <= 40 => { - event!(target: "mpv_event", Level::INFO, "{}", event_text) + event!(target: "mpv_event", Level::INFO, "{}", event.text.trim()) } l if l <= 60 => { - event!(target: "mpv_event", Level::DEBUG, "{}", event_text) + event!(target: "mpv_event", Level::DEBUG, "{}", event.text.trim()) } l if l <= 70 => { - event!(target: "mpv_event", Level::TRACE, "{}", event_text) + event!(target: "mpv_event", Level::TRACE, "{}", event.text.trim()) } // should be unused _ => event!( @@ -550,7 +543,7 @@ mod imp { Level::DEBUG, log_level = event.log_level, "{}", - event_text, + event.text.trim(), ), }; }