about summary refs log tree commit diff stats
path: root/crates/yt_dlp/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--crates/yt_dlp/src/lib.rs8
1 files changed, 7 insertions, 1 deletions
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<String, Value> = serde_json::from_str(&json_dumps(
         py,
         input