mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-06-02 13:29:29 +00:00
log: DebugCategoryLogger is optional via 'log' feature
This commit is contained in:
parent
1438fa88db
commit
8dd9a2d5ee
|
@ -23,7 +23,7 @@ num-rational = { version = "0.4", default-features = false, features = [] }
|
||||||
futures-core = "0.3"
|
futures-core = "0.3"
|
||||||
futures-channel = "0.3"
|
futures-channel = "0.3"
|
||||||
futures-util = { version = "0.3", default-features = false }
|
futures-util = { version = "0.3", default-features = false }
|
||||||
log = "0.4"
|
log = { version = "0.4", optional = true }
|
||||||
muldiv = "1"
|
muldiv = "1"
|
||||||
opt-ops = { package = "option-operations", version = "0.5" }
|
opt-ops = { package = "option-operations", version = "0.5" }
|
||||||
serde = { version = "1.0", optional = true, features = ["derive"] }
|
serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||||
|
@ -49,6 +49,7 @@ v1_20 = ["ffi/v1_20", "v1_18"]
|
||||||
v1_22 = ["ffi/v1_22", "v1_20"]
|
v1_22 = ["ffi/v1_22", "v1_20"]
|
||||||
v1_24 = ["ffi/v1_24", "v1_22"]
|
v1_24 = ["ffi/v1_24", "v1_22"]
|
||||||
serde = ["num-rational/serde", "dep:serde", "serde_bytes"]
|
serde = ["num-rational/serde", "dep:serde", "serde_bytes"]
|
||||||
|
log = ["dep:log"]
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
|
|
@ -49,13 +49,15 @@ mod serde_macros;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod log;
|
pub mod log;
|
||||||
|
#[cfg(feature = "log")]
|
||||||
|
pub use crate::log::DebugCategoryLogger;
|
||||||
pub use crate::log::{
|
pub use crate::log::{
|
||||||
DebugCategory, DebugCategoryLogger, DebugLogFunction, DebugMessage, LoggedObject, CAT_BUFFER,
|
DebugCategory, DebugLogFunction, DebugMessage, LoggedObject, CAT_BUFFER, CAT_BUFFER_LIST,
|
||||||
CAT_BUFFER_LIST, CAT_BUS, CAT_CALL_TRACE, CAT_CAPS, CAT_CLOCK, CAT_CONTEXT, CAT_DEFAULT,
|
CAT_BUS, CAT_CALL_TRACE, CAT_CAPS, CAT_CLOCK, CAT_CONTEXT, CAT_DEFAULT, CAT_ELEMENT_PADS,
|
||||||
CAT_ELEMENT_PADS, CAT_ERROR_SYSTEM, CAT_EVENT, CAT_GST_INIT, CAT_LOCKING, CAT_MEMORY,
|
CAT_ERROR_SYSTEM, CAT_EVENT, CAT_GST_INIT, CAT_LOCKING, CAT_MEMORY, CAT_MESSAGE, CAT_META,
|
||||||
CAT_MESSAGE, CAT_META, CAT_NEGOTIATION, CAT_PADS, CAT_PARAMS, CAT_PARENTAGE, CAT_PERFORMANCE,
|
CAT_NEGOTIATION, CAT_PADS, CAT_PARAMS, CAT_PARENTAGE, CAT_PERFORMANCE, CAT_PIPELINE,
|
||||||
CAT_PIPELINE, CAT_PLUGIN_INFO, CAT_PLUGIN_LOADING, CAT_PROBE, CAT_PROPERTIES, CAT_QOS,
|
CAT_PLUGIN_INFO, CAT_PLUGIN_LOADING, CAT_PROBE, CAT_PROPERTIES, CAT_QOS, CAT_REFCOUNTING,
|
||||||
CAT_REFCOUNTING, CAT_REGISTRY, CAT_RUST, CAT_SCHEDULING, CAT_SIGNAL, CAT_STATES,
|
CAT_REGISTRY, CAT_RUST, CAT_SCHEDULING, CAT_SIGNAL, CAT_STATES,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
|
|
@ -4,6 +4,7 @@ use std::{borrow::Cow, ffi::CStr, fmt, ptr};
|
||||||
|
|
||||||
use glib::{ffi::gpointer, prelude::*, translate::*};
|
use glib::{ffi::gpointer, prelude::*, translate::*};
|
||||||
use libc::c_char;
|
use libc::c_char;
|
||||||
|
#[cfg(feature = "log")]
|
||||||
use log;
|
use log;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
|
@ -1065,15 +1066,18 @@ macro_rules! log_with_level(
|
||||||
}};
|
}};
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(feature = "log")]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DebugCategoryLogger(DebugCategory);
|
pub struct DebugCategoryLogger(DebugCategory);
|
||||||
|
|
||||||
|
#[cfg(feature = "log")]
|
||||||
impl DebugCategoryLogger {
|
impl DebugCategoryLogger {
|
||||||
pub fn new(cat: DebugCategory) -> Self {
|
pub fn new(cat: DebugCategory) -> Self {
|
||||||
Self(cat)
|
Self(cat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "log")]
|
||||||
impl log::Log for DebugCategoryLogger {
|
impl log::Log for DebugCategoryLogger {
|
||||||
fn enabled(&self, _metadata: &log::Metadata) -> bool {
|
fn enabled(&self, _metadata: &log::Metadata) -> bool {
|
||||||
true
|
true
|
||||||
|
@ -1346,6 +1350,7 @@ mod tests {
|
||||||
memdump!(cat, obj: obj, "meh");
|
memdump!(cat, obj: obj, "meh");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "log")]
|
||||||
static LOGGER: Lazy<DebugCategoryLogger> = Lazy::new(|| {
|
static LOGGER: Lazy<DebugCategoryLogger> = Lazy::new(|| {
|
||||||
DebugCategoryLogger::new(DebugCategory::new(
|
DebugCategoryLogger::new(DebugCategory::new(
|
||||||
"Log_trait",
|
"Log_trait",
|
||||||
|
@ -1355,6 +1360,7 @@ mod tests {
|
||||||
});
|
});
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg(feature = "log")]
|
||||||
fn log_trait() {
|
fn log_trait() {
|
||||||
crate::init().unwrap();
|
crate::init().unwrap();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue