From 5e46f4726f308cbe25a84e71e083ffe99e9e4c2d Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 25 Aug 2024 15:44:49 +0200 Subject: fix(yt_dlp/lib/hook): Don't print download progress, when debug is logged This makes interpreting the debug output easier. --- crates/yt_dlp/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'crates/yt_dlp/src/lib.rs') diff --git a/crates/yt_dlp/src/lib.rs b/crates/yt_dlp/src/lib.rs index 37d0945..d9b10c2 100644 --- a/crates/yt_dlp/src/lib.rs +++ b/crates/yt_dlp/src/lib.rs @@ -15,7 +15,7 @@ use std::{path::PathBuf, sync::Once}; use crate::{duration::Duration, logging::setup_logging, wrapper::info_json::InfoJson}; use bytes::Bytes; -use log::{info, warn}; +use log::{info, log_enabled, warn, Level}; use pyo3::types::{PyString, PyTuple, PyTupleMethods}; use pyo3::{ pyfunction, @@ -82,6 +82,12 @@ signal.signal(signal.SIGINT, signal.SIG_DFL) #[pyfunction] pub fn progress_hook<'a>(py: Python, input: Bound<'_, PyDict>) -> PyResult<()> { + // Only add the handler, if the log-level is higher than Debug (this avoids covering debug + // messages). + if log_enabled!(Level::Debug) { + return Ok(()); + } + let input: serde_json::Map = serde_json::from_str(&json_dumps( py, input -- cgit 1.4.1