mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 17:41:05 +00:00
gstreamer: move debug_* functions to their own module
Better namespacing so the API is more Rust-y. Fix #500 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1355>
This commit is contained in:
parent
7f234c88ac
commit
f255b82b55
7 changed files with 45 additions and 26 deletions
|
@ -19,11 +19,11 @@ fn example_main() {
|
||||||
|
|
||||||
/* Disable stdout debug, then configure the debug ringbuffer and enable
|
/* Disable stdout debug, then configure the debug ringbuffer and enable
|
||||||
* all debug */
|
* all debug */
|
||||||
gst::debug_remove_default_log_function();
|
gst::log::remove_default_log_function();
|
||||||
/* Keep 1KB of logs per thread, removing old threads after 10 seconds */
|
/* Keep 1KB of logs per thread, removing old threads after 10 seconds */
|
||||||
gst::debug_add_ring_buffer_logger(1024, 10);
|
gst::log::add_ring_buffer_logger(1024, 10);
|
||||||
/* Enable all debug categories */
|
/* Enable all debug categories */
|
||||||
gst::debug_set_default_threshold(gst::DebugLevel::Log);
|
gst::log::set_default_threshold(gst::DebugLevel::Log);
|
||||||
|
|
||||||
let mut context = gst::ParseContext::new();
|
let mut context = gst::ParseContext::new();
|
||||||
let pipeline =
|
let pipeline =
|
||||||
|
@ -73,7 +73,7 @@ fn example_main() {
|
||||||
gst::error!(gst::CAT_DEFAULT, "Hi from the debug log ringbuffer example");
|
gst::error!(gst::CAT_DEFAULT, "Hi from the debug log ringbuffer example");
|
||||||
|
|
||||||
println!("Dumping debug logs\n");
|
println!("Dumping debug logs\n");
|
||||||
for s in gst::debug_ring_buffer_logger_get_logs().iter() {
|
for s in gst::log::ring_buffer_logger_get_logs().iter() {
|
||||||
println!("{s}\n------------------");
|
println!("{s}\n------------------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,11 +252,7 @@ fn example_main() -> Result<(), Error> {
|
||||||
if let Some(element) = msg.src() {
|
if let Some(element) = msg.src() {
|
||||||
if element == &pipeline && s.current() == gst::State::Playing {
|
if element == &pipeline && s.current() == gst::State::Playing {
|
||||||
eprintln!("PLAYING");
|
eprintln!("PLAYING");
|
||||||
gst::debug_bin_to_dot_file(
|
pipeline.debug_to_dot_file(gst::DebugGraphDetails::all(), "client-playing");
|
||||||
&pipeline,
|
|
||||||
gst::DebugGraphDetails::all(),
|
|
||||||
"client-playing",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,11 +179,7 @@ fn example_main() -> Result<(), Error> {
|
||||||
if let Some(element) = msg.src() {
|
if let Some(element) = msg.src() {
|
||||||
if element == &pipeline && s.current() == gst::State::Playing {
|
if element == &pipeline && s.current() == gst::State::Playing {
|
||||||
eprintln!("PLAYING");
|
eprintln!("PLAYING");
|
||||||
gst::debug_bin_to_dot_file(
|
pipeline.debug_to_dot_file(gst::DebugGraphDetails::all(), "server-playing");
|
||||||
&pipeline,
|
|
||||||
gst::DebugGraphDetails::all(),
|
|
||||||
"server-playing",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,7 +164,7 @@ pub trait GstBinExtManual: sealed::Sealed + IsA<Bin> + 'static {
|
||||||
|
|
||||||
#[doc(alias = "gst_debug_bin_to_dot_data")]
|
#[doc(alias = "gst_debug_bin_to_dot_data")]
|
||||||
fn debug_to_dot_data(&self, details: crate::DebugGraphDetails) -> GString {
|
fn debug_to_dot_data(&self, details: crate::DebugGraphDetails) -> GString {
|
||||||
crate::debug_bin_to_dot_data(self, details)
|
crate::auto::functions::debug_bin_to_dot_data(self, details)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "GST_DEBUG_BIN_TO_DOT_FILE")]
|
#[doc(alias = "GST_DEBUG_BIN_TO_DOT_FILE")]
|
||||||
|
@ -174,7 +174,7 @@ pub trait GstBinExtManual: sealed::Sealed + IsA<Bin> + 'static {
|
||||||
details: crate::DebugGraphDetails,
|
details: crate::DebugGraphDetails,
|
||||||
file_name: impl AsRef<path::Path>,
|
file_name: impl AsRef<path::Path>,
|
||||||
) {
|
) {
|
||||||
crate::debug_bin_to_dot_file(self, details, file_name)
|
crate::auto::functions::debug_bin_to_dot_file(self, details, file_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS")]
|
#[doc(alias = "GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS")]
|
||||||
|
@ -184,7 +184,7 @@ pub trait GstBinExtManual: sealed::Sealed + IsA<Bin> + 'static {
|
||||||
details: crate::DebugGraphDetails,
|
details: crate::DebugGraphDetails,
|
||||||
file_name: impl AsRef<path::Path>,
|
file_name: impl AsRef<path::Path>,
|
||||||
) {
|
) {
|
||||||
crate::debug_bin_to_dot_file_with_ts(self, details, file_name)
|
crate::auto::functions::debug_bin_to_dot_file_with_ts(self, details, file_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_bin_flags(&self, flags: BinFlags) {
|
fn set_bin_flags(&self, flags: BinFlags) {
|
||||||
|
|
|
@ -9,7 +9,11 @@ use glib::{prelude::*, translate::*};
|
||||||
use crate::Tracer;
|
use crate::Tracer;
|
||||||
use crate::{Bin, Element, Object, ParseContext, ParseFlags};
|
use crate::{Bin, Element, Object, ParseContext, ParseFlags};
|
||||||
|
|
||||||
pub use crate::auto::functions::*;
|
// import only functions which do not have their own module as namespace
|
||||||
|
pub use crate::auto::functions::{
|
||||||
|
main_executable_path, parse_bin_from_description, parse_launch, parse_launchv, update_registry,
|
||||||
|
util_get_timestamp, version, version_string,
|
||||||
|
};
|
||||||
|
|
||||||
pub fn parse_bin_from_description_with_name(
|
pub fn parse_bin_from_description_with_name(
|
||||||
bin_description: &str,
|
bin_description: &str,
|
||||||
|
|
|
@ -50,8 +50,15 @@ mod serde_macros;
|
||||||
pub use crate::serde_macros::*;
|
pub use crate::serde_macros::*;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod log;
|
pub mod log;
|
||||||
pub use crate::log::*;
|
pub use crate::log::{
|
||||||
|
DebugCategory, DebugLogFunction, DebugMessage, LoggedObject, CAT_BUFFER, CAT_BUFFER_LIST,
|
||||||
|
CAT_BUS, CAT_CALL_TRACE, CAT_CAPS, CAT_CLOCK, CAT_CONTEXT, CAT_DEFAULT, CAT_ELEMENT_PADS,
|
||||||
|
CAT_ERROR_SYSTEM, CAT_EVENT, CAT_GST_INIT, CAT_LOCKING, CAT_MEMORY, CAT_MESSAGE, CAT_META,
|
||||||
|
CAT_NEGOTIATION, CAT_PADS, CAT_PARAMS, CAT_PARENTAGE, CAT_PERFORMANCE, CAT_PIPELINE,
|
||||||
|
CAT_PLUGIN_INFO, CAT_PLUGIN_LOADING, CAT_PROBE, CAT_PROPERTIES, CAT_QOS, CAT_REFCOUNTING,
|
||||||
|
CAT_REGISTRY, CAT_RUST, CAT_SCHEDULING, CAT_SIGNAL, CAT_STATES,
|
||||||
|
};
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod error;
|
mod error;
|
||||||
|
|
|
@ -8,6 +8,22 @@ use libc::c_char;
|
||||||
|
|
||||||
use crate::DebugLevel;
|
use crate::DebugLevel;
|
||||||
|
|
||||||
|
// import and rename those so they are namespaced as log::*
|
||||||
|
pub use crate::auto::functions::debug_add_ring_buffer_logger as add_ring_buffer_logger;
|
||||||
|
pub use crate::auto::functions::debug_get_default_threshold as get_default_threshold;
|
||||||
|
pub use crate::auto::functions::debug_get_stack_trace as get_stack_trace;
|
||||||
|
pub use crate::auto::functions::debug_is_active as is_active;
|
||||||
|
pub use crate::auto::functions::debug_is_colored as is_colored;
|
||||||
|
pub use crate::auto::functions::debug_print_stack_trace as print_stack_trace;
|
||||||
|
pub use crate::auto::functions::debug_remove_ring_buffer_logger as remove_ring_buffer_logger;
|
||||||
|
pub use crate::auto::functions::debug_ring_buffer_logger_get_logs as ring_buffer_logger_get_logs;
|
||||||
|
pub use crate::auto::functions::debug_set_active as set_active;
|
||||||
|
pub use crate::auto::functions::debug_set_colored as set_colored;
|
||||||
|
pub use crate::auto::functions::debug_set_default_threshold as set_default_threshold;
|
||||||
|
pub use crate::auto::functions::debug_set_threshold_for_name as set_threshold_for_name;
|
||||||
|
pub use crate::auto::functions::debug_set_threshold_from_string as set_threshold_from_string;
|
||||||
|
pub use crate::auto::functions::debug_unset_threshold_for_name as unset_threshold_for_name;
|
||||||
|
|
||||||
#[derive(PartialEq, Eq)]
|
#[derive(PartialEq, Eq)]
|
||||||
#[doc(alias = "GstDebugMessage")]
|
#[doc(alias = "GstDebugMessage")]
|
||||||
pub struct DebugMessage(ptr::NonNull<ffi::GstDebugMessage>);
|
pub struct DebugMessage(ptr::NonNull<ffi::GstDebugMessage>);
|
||||||
|
@ -1185,7 +1201,7 @@ impl fmt::Display for LoggedObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_debug_add_log_function")]
|
#[doc(alias = "gst_debug_add_log_function")]
|
||||||
pub fn debug_add_log_function<T>(function: T) -> DebugLogFunction
|
pub fn add_log_function<T>(function: T) -> DebugLogFunction
|
||||||
where
|
where
|
||||||
T: Fn(
|
T: Fn(
|
||||||
DebugCategory,
|
DebugCategory,
|
||||||
|
@ -1212,7 +1228,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn debug_remove_default_log_function() {
|
pub fn remove_default_log_function() {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_debug_remove_log_function(None);
|
ffi::gst_debug_remove_log_function(None);
|
||||||
|
@ -1220,7 +1236,7 @@ pub fn debug_remove_default_log_function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_debug_remove_log_function_by_data")]
|
#[doc(alias = "gst_debug_remove_log_function_by_data")]
|
||||||
pub fn debug_remove_log_function(log_fn: DebugLogFunction) {
|
pub fn remove_log_function(log_fn: DebugLogFunction) {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_debug_remove_log_function_by_data(log_fn.0.as_ptr());
|
ffi::gst_debug_remove_log_function_by_data(log_fn.0.as_ptr());
|
||||||
|
@ -1328,13 +1344,13 @@ mod tests {
|
||||||
let _ = sender.lock().unwrap().send(());
|
let _ = sender.lock().unwrap().send(());
|
||||||
};
|
};
|
||||||
|
|
||||||
debug_remove_default_log_function();
|
remove_default_log_function();
|
||||||
let log_fn = debug_add_log_function(handler);
|
let log_fn = add_log_function(handler);
|
||||||
info!(cat, obj: &obj, "meh");
|
info!(cat, obj: &obj, "meh");
|
||||||
|
|
||||||
receiver.recv().unwrap();
|
receiver.recv().unwrap();
|
||||||
|
|
||||||
debug_remove_log_function(log_fn);
|
remove_log_function(log_fn);
|
||||||
|
|
||||||
info!(cat, obj: &obj, "meh2");
|
info!(cat, obj: &obj, "meh2");
|
||||||
assert!(receiver.recv().is_err());
|
assert!(receiver.recv().is_err());
|
||||||
|
|
Loading…
Reference in a new issue