Revert "don't print auth token on mpv logs"

This reverts commit e52adda2ed.

guilty
This commit is contained in:
Erica Z 2024-11-07 11:41:41 +01:00
parent 0cbf091b91
commit 62d9f74a39
2 changed files with 6 additions and 19 deletions

View file

@ -52,7 +52,6 @@ impl From<reqwest::Error> 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<T: serde::de::DeserializeOwned + Send + 'static>(
&self,
request: reqwest::RequestBuilder,

View file

@ -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(),
),
};
}