mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-23 08:36:31 +00:00
gstreamer: Don't inline debug logging function
It's relatively big and increases code size and stack usage quite a bit, and having a function call for logging is not going to make much of a difference as it happens *after* filtering for the debug level threshold. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1179>
This commit is contained in:
parent
036a020b62
commit
06a0dbacba
2 changed files with 221 additions and 221 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use glib::prelude::*;
|
use glib::{prelude::*, IntoGStr};
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! error_msg(
|
macro_rules! error_msg(
|
||||||
|
@ -123,39 +123,42 @@ impl LoggableError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(never)]
|
||||||
pub fn log(&self) {
|
pub fn log(&self) {
|
||||||
|
self.bool_error.filename.run_with_gstr(|filename| {
|
||||||
self.category.log(
|
self.category.log(
|
||||||
None as Option<&glib::Object>,
|
None::<&glib::Object>,
|
||||||
crate::DebugLevel::Error,
|
crate::DebugLevel::Error,
|
||||||
glib::GString::from(self.bool_error.filename).as_gstr(),
|
filename,
|
||||||
glib::GString::from(self.bool_error.function).as_gstr(),
|
self.bool_error.function,
|
||||||
self.bool_error.line,
|
self.bool_error.line,
|
||||||
format_args!("{}", self.bool_error.message),
|
format_args!("{}", self.bool_error.message),
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn log_with_object<O: IsA<glib::Object>>(&self, obj: &O) {
|
pub fn log_with_object(&self, obj: &impl IsA<glib::Object>) {
|
||||||
|
self.log_with_object_internal(obj.as_ref());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(never)]
|
||||||
|
fn log_with_object_internal(&self, obj: &glib::Object) {
|
||||||
|
self.bool_error.filename.run_with_gstr(|filename| {
|
||||||
self.category.log(
|
self.category.log(
|
||||||
Some(obj),
|
Some(obj),
|
||||||
crate::DebugLevel::Error,
|
crate::DebugLevel::Error,
|
||||||
glib::GString::from(self.bool_error.filename).as_gstr(),
|
filename,
|
||||||
glib::GString::from(self.bool_error.function).as_gstr(),
|
self.bool_error.function,
|
||||||
self.bool_error.line,
|
self.bool_error.line,
|
||||||
format_args!("{}", self.bool_error.message),
|
format_args!("{}", self.bool_error.message),
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn log_with_imp<I: glib::subclass::prelude::ObjectSubclass>(&self, imp: &I) {
|
pub fn log_with_imp(&self, imp: &impl glib::subclass::types::ObjectSubclass) {
|
||||||
use glib::subclass::prelude::*;
|
use glib::subclass::prelude::*;
|
||||||
|
|
||||||
self.category.log(
|
self.log_with_object_internal(unsafe { imp.obj().unsafe_cast_ref::<glib::Object>() });
|
||||||
Some(unsafe { imp.obj().unsafe_cast_ref::<glib::Object>() }),
|
|
||||||
crate::DebugLevel::Error,
|
|
||||||
glib::GString::from(self.bool_error.filename).as_gstr(),
|
|
||||||
glib::GString::from(self.bool_error.function).as_gstr(),
|
|
||||||
self.bool_error.line,
|
|
||||||
format_args!("{}", self.bool_error.message),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn category(&self) -> crate::DebugCategory {
|
pub fn category(&self) -> crate::DebugCategory {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use crate::DebugLevel;
|
use crate::DebugLevel;
|
||||||
|
|
||||||
|
use glib::IntoGStr;
|
||||||
use libc::c_char;
|
use libc::c_char;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
|
@ -179,7 +180,7 @@ impl DebugCategory {
|
||||||
obj: Option<&impl IsA<glib::Object>>,
|
obj: Option<&impl IsA<glib::Object>>,
|
||||||
level: crate::DebugLevel,
|
level: crate::DebugLevel,
|
||||||
file: &glib::GStr,
|
file: &glib::GStr,
|
||||||
function: &glib::GStr,
|
function: &str,
|
||||||
line: u32,
|
line: u32,
|
||||||
args: fmt::Arguments,
|
args: fmt::Arguments,
|
||||||
) {
|
) {
|
||||||
|
@ -187,7 +188,14 @@ impl DebugCategory {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.log_unfiltered(obj, level, file, function, line, args)
|
self.log_unfiltered_internal(
|
||||||
|
obj.map(|obj| obj.as_ref()),
|
||||||
|
level,
|
||||||
|
file,
|
||||||
|
function,
|
||||||
|
line,
|
||||||
|
args,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -197,7 +205,7 @@ impl DebugCategory {
|
||||||
obj: Option<&impl IsA<glib::Object>>,
|
obj: Option<&impl IsA<glib::Object>>,
|
||||||
level: crate::DebugLevel,
|
level: crate::DebugLevel,
|
||||||
file: &glib::GStr,
|
file: &glib::GStr,
|
||||||
function: &glib::GStr,
|
function: &str,
|
||||||
line: u32,
|
line: u32,
|
||||||
msg: &glib::GStr,
|
msg: &glib::GStr,
|
||||||
) {
|
) {
|
||||||
|
@ -205,7 +213,14 @@ impl DebugCategory {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.log_literal_unfiltered(obj, level, file, function, line, msg)
|
self.log_literal_unfiltered_internal(
|
||||||
|
obj.map(|obj| obj.as_ref()),
|
||||||
|
level,
|
||||||
|
file,
|
||||||
|
function,
|
||||||
|
line,
|
||||||
|
msg,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// rustdoc-stripper-ignore-next
|
// rustdoc-stripper-ignore-next
|
||||||
|
@ -217,18 +232,18 @@ impl DebugCategory {
|
||||||
obj: Option<&impl IsA<glib::Object>>,
|
obj: Option<&impl IsA<glib::Object>>,
|
||||||
level: crate::DebugLevel,
|
level: crate::DebugLevel,
|
||||||
file: &glib::GStr,
|
file: &glib::GStr,
|
||||||
function: &glib::GStr,
|
function: &str,
|
||||||
line: u32,
|
line: u32,
|
||||||
args: fmt::Arguments,
|
args: fmt::Arguments,
|
||||||
) {
|
) {
|
||||||
let mut w = glib::GStringBuilder::default();
|
self.log_unfiltered_internal(
|
||||||
|
obj.map(|obj| obj.as_ref()),
|
||||||
// Can't really happen but better safe than sorry
|
level,
|
||||||
if fmt::write(&mut w, args).is_err() {
|
file,
|
||||||
return;
|
function,
|
||||||
}
|
line,
|
||||||
|
args,
|
||||||
self.log_literal_unfiltered(obj, level, file, function, line, w.into_string().as_gstr());
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// rustdoc-stripper-ignore-next
|
// rustdoc-stripper-ignore-next
|
||||||
|
@ -240,7 +255,54 @@ impl DebugCategory {
|
||||||
obj: Option<&impl IsA<glib::Object>>,
|
obj: Option<&impl IsA<glib::Object>>,
|
||||||
level: crate::DebugLevel,
|
level: crate::DebugLevel,
|
||||||
file: &glib::GStr,
|
file: &glib::GStr,
|
||||||
function: &glib::GStr,
|
function: &str,
|
||||||
|
line: u32,
|
||||||
|
msg: &glib::GStr,
|
||||||
|
) {
|
||||||
|
self.log_literal_unfiltered_internal(
|
||||||
|
obj.map(|obj| obj.as_ref()),
|
||||||
|
level,
|
||||||
|
file,
|
||||||
|
function,
|
||||||
|
line,
|
||||||
|
msg,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(never)]
|
||||||
|
fn log_unfiltered_internal(
|
||||||
|
self,
|
||||||
|
obj: Option<&glib::Object>,
|
||||||
|
level: crate::DebugLevel,
|
||||||
|
file: &glib::GStr,
|
||||||
|
function: &str,
|
||||||
|
line: u32,
|
||||||
|
args: fmt::Arguments,
|
||||||
|
) {
|
||||||
|
let mut w = glib::GStringBuilder::default();
|
||||||
|
|
||||||
|
// Can't really happen but better safe than sorry
|
||||||
|
if fmt::write(&mut w, args).is_err() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.log_literal_unfiltered_internal(
|
||||||
|
obj,
|
||||||
|
level,
|
||||||
|
file,
|
||||||
|
function,
|
||||||
|
line,
|
||||||
|
w.into_string().as_gstr(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(never)]
|
||||||
|
fn log_literal_unfiltered_internal(
|
||||||
|
self,
|
||||||
|
obj: Option<&glib::Object>,
|
||||||
|
level: crate::DebugLevel,
|
||||||
|
file: &glib::GStr,
|
||||||
|
function: &str,
|
||||||
line: u32,
|
line: u32,
|
||||||
msg: &glib::GStr,
|
msg: &glib::GStr,
|
||||||
) {
|
) {
|
||||||
|
@ -250,10 +312,11 @@ impl DebugCategory {
|
||||||
};
|
};
|
||||||
|
|
||||||
let obj_ptr = match obj {
|
let obj_ptr = match obj {
|
||||||
Some(obj) => obj.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
|
Some(obj) => obj.as_ptr(),
|
||||||
None => ptr::null_mut(),
|
None => ptr::null_mut(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function.run_with_gstr(|function| {
|
||||||
#[cfg(feature = "v1_20")]
|
#[cfg(feature = "v1_20")]
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_debug_log_literal(
|
ffi::gst_debug_log_literal(
|
||||||
|
@ -279,6 +342,7 @@ impl DebugCategory {
|
||||||
msg.as_ptr(),
|
msg.as_ptr(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
||||||
|
@ -287,10 +351,10 @@ impl DebugCategory {
|
||||||
#[doc(alias = "gst_debug_log_id")]
|
#[doc(alias = "gst_debug_log_id")]
|
||||||
pub fn log_id(
|
pub fn log_id(
|
||||||
self,
|
self,
|
||||||
id: Option<impl AsRef<glib::GStr>>,
|
id: impl AsRef<glib::GStr>,
|
||||||
level: crate::DebugLevel,
|
level: crate::DebugLevel,
|
||||||
file: &glib::GStr,
|
file: &glib::GStr,
|
||||||
function: &glib::GStr,
|
function: &str,
|
||||||
line: u32,
|
line: u32,
|
||||||
args: fmt::Arguments,
|
args: fmt::Arguments,
|
||||||
) {
|
) {
|
||||||
|
@ -298,14 +362,7 @@ impl DebugCategory {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut w = glib::GStringBuilder::default();
|
self.log_id_unfiltered_internal(id.as_ref(), level, file, function, line, args);
|
||||||
|
|
||||||
// Can't really happen but better safe than sorry
|
|
||||||
if fmt::write(&mut w, args).is_err() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.log_id_literal_unfiltered(id, level, file, function, line, w.into_string().as_gstr());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
||||||
|
@ -314,10 +371,10 @@ impl DebugCategory {
|
||||||
#[doc(alias = "gst_debug_log_id_literal")]
|
#[doc(alias = "gst_debug_log_id_literal")]
|
||||||
pub fn log_id_literal(
|
pub fn log_id_literal(
|
||||||
self,
|
self,
|
||||||
id: Option<impl AsRef<glib::GStr>>,
|
id: impl AsRef<glib::GStr>,
|
||||||
level: crate::DebugLevel,
|
level: crate::DebugLevel,
|
||||||
file: &glib::GStr,
|
file: &glib::GStr,
|
||||||
function: &glib::GStr,
|
function: &str,
|
||||||
line: u32,
|
line: u32,
|
||||||
msg: &glib::GStr,
|
msg: &glib::GStr,
|
||||||
) {
|
) {
|
||||||
|
@ -325,7 +382,7 @@ impl DebugCategory {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.log_id_literal_unfiltered(id, level, file, function, line, msg);
|
self.log_id_literal_unfiltered_internal(id.as_ref(), level, file, function, line, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
||||||
|
@ -336,21 +393,14 @@ impl DebugCategory {
|
||||||
#[doc(alias = "gst_debug_log_id")]
|
#[doc(alias = "gst_debug_log_id")]
|
||||||
pub fn log_id_unfiltered(
|
pub fn log_id_unfiltered(
|
||||||
self,
|
self,
|
||||||
id: Option<impl AsRef<glib::GStr>>,
|
id: impl AsRef<glib::GStr>,
|
||||||
level: crate::DebugLevel,
|
level: crate::DebugLevel,
|
||||||
file: &glib::GStr,
|
file: &glib::GStr,
|
||||||
function: &glib::GStr,
|
function: &str,
|
||||||
line: u32,
|
line: u32,
|
||||||
args: fmt::Arguments,
|
args: fmt::Arguments,
|
||||||
) {
|
) {
|
||||||
let mut w = glib::GStringBuilder::default();
|
self.log_id_unfiltered_internal(id.as_ref(), level, file, function, line, args)
|
||||||
|
|
||||||
// Can't really happen but better safe than sorry
|
|
||||||
if fmt::write(&mut w, args).is_err() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.log_id_literal_unfiltered(id, level, file, function, line, w.into_string().as_gstr());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
||||||
|
@ -361,10 +411,52 @@ impl DebugCategory {
|
||||||
#[doc(alias = "gst_debug_log_id_literal")]
|
#[doc(alias = "gst_debug_log_id_literal")]
|
||||||
pub fn log_id_literal_unfiltered(
|
pub fn log_id_literal_unfiltered(
|
||||||
self,
|
self,
|
||||||
id: Option<impl AsRef<glib::GStr>>,
|
id: impl AsRef<glib::GStr>,
|
||||||
level: crate::DebugLevel,
|
level: crate::DebugLevel,
|
||||||
file: &glib::GStr,
|
file: &glib::GStr,
|
||||||
function: &glib::GStr,
|
function: &str,
|
||||||
|
line: u32,
|
||||||
|
msg: &glib::GStr,
|
||||||
|
) {
|
||||||
|
self.log_id_literal_unfiltered_internal(id.as_ref(), level, file, function, line, msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
||||||
|
#[inline(never)]
|
||||||
|
fn log_id_unfiltered_internal(
|
||||||
|
self,
|
||||||
|
id: &glib::GStr,
|
||||||
|
level: crate::DebugLevel,
|
||||||
|
file: &glib::GStr,
|
||||||
|
function: &str,
|
||||||
|
line: u32,
|
||||||
|
args: fmt::Arguments,
|
||||||
|
) {
|
||||||
|
let mut w = glib::GStringBuilder::default();
|
||||||
|
|
||||||
|
// Can't really happen but better safe than sorry
|
||||||
|
if fmt::write(&mut w, args).is_err() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.log_id_literal_unfiltered_internal(
|
||||||
|
id,
|
||||||
|
level,
|
||||||
|
file,
|
||||||
|
function,
|
||||||
|
line,
|
||||||
|
w.into_string().as_gstr(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
||||||
|
#[inline(never)]
|
||||||
|
fn log_id_literal_unfiltered_internal(
|
||||||
|
self,
|
||||||
|
id: &glib::GStr,
|
||||||
|
level: crate::DebugLevel,
|
||||||
|
file: &glib::GStr,
|
||||||
|
function: &str,
|
||||||
line: u32,
|
line: u32,
|
||||||
msg: &glib::GStr,
|
msg: &glib::GStr,
|
||||||
) {
|
) {
|
||||||
|
@ -373,22 +465,17 @@ impl DebugCategory {
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
let id = match id {
|
function.run_with_gstr(|function| unsafe {
|
||||||
None => ptr::null(),
|
|
||||||
Some(id) => id.as_ref().as_ptr(),
|
|
||||||
};
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
ffi::gst_debug_log_id_literal(
|
ffi::gst_debug_log_id_literal(
|
||||||
cat.as_ptr(),
|
cat.as_ptr(),
|
||||||
level.into_glib(),
|
level.into_glib(),
|
||||||
file.as_ptr(),
|
file.as_ptr(),
|
||||||
function.as_ptr(),
|
function.as_ptr(),
|
||||||
line as i32,
|
line as i32,
|
||||||
id,
|
id.as_ptr(),
|
||||||
msg.as_ptr(),
|
msg.as_ptr(),
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "get_all_categories")]
|
#[doc(alias = "get_all_categories")]
|
||||||
|
@ -641,16 +728,7 @@ macro_rules! log_with_level(
|
||||||
use $crate::glib::Cast;
|
use $crate::glib::Cast;
|
||||||
|
|
||||||
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
||||||
// avoid this complication
|
// directly pass it as `&GStr` forward
|
||||||
let function_name = $crate::glib::function_name!();
|
|
||||||
let function_name_len = function_name.len();
|
|
||||||
let mut storage = [0u8; 256];
|
|
||||||
let function_name = if function_name_len < 256 {
|
|
||||||
storage[0..function_name_len].copy_from_slice(function_name.as_bytes());
|
|
||||||
::std::borrow::Cow::Borrowed(unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(&storage[..function_name_len+1]) })
|
|
||||||
} else {
|
|
||||||
::std::borrow::Cow::Owned($crate::glib::GString::from(function_name))
|
|
||||||
};
|
|
||||||
|
|
||||||
let obj = unsafe { $obj.unsafe_cast_ref::<$crate::glib::Object>() };
|
let obj = unsafe { $obj.unsafe_cast_ref::<$crate::glib::Object>() };
|
||||||
|
|
||||||
|
@ -664,7 +742,7 @@ macro_rules! log_with_level(
|
||||||
Some(obj),
|
Some(obj),
|
||||||
$level,
|
$level,
|
||||||
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
||||||
function_name.as_ref(),
|
$crate::glib::function_name!(),
|
||||||
line!(),
|
line!(),
|
||||||
$crate::glib::gstr!($msg),
|
$crate::glib::gstr!($msg),
|
||||||
)
|
)
|
||||||
|
@ -674,7 +752,7 @@ macro_rules! log_with_level(
|
||||||
Some(obj),
|
Some(obj),
|
||||||
$level,
|
$level,
|
||||||
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
||||||
function_name.as_ref(),
|
$crate::glib::function_name!(),
|
||||||
line!(),
|
line!(),
|
||||||
args,
|
args,
|
||||||
)
|
)
|
||||||
|
@ -690,16 +768,7 @@ macro_rules! log_with_level(
|
||||||
use $crate::glib::Cast;
|
use $crate::glib::Cast;
|
||||||
|
|
||||||
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
||||||
// avoid this complication
|
// directly pass it as `&GStr` forward
|
||||||
let function_name = $crate::glib::function_name!();
|
|
||||||
let function_name_len = function_name.len();
|
|
||||||
let mut storage = [0u8; 256];
|
|
||||||
let function_name = if function_name_len < 256 {
|
|
||||||
storage[0..function_name_len].copy_from_slice(function_name.as_bytes());
|
|
||||||
::std::borrow::Cow::Borrowed(unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(&storage[..function_name_len+1]) })
|
|
||||||
} else {
|
|
||||||
::std::borrow::Cow::Owned($crate::glib::GString::from(function_name))
|
|
||||||
};
|
|
||||||
|
|
||||||
let obj = unsafe { $obj.unsafe_cast_ref::<$crate::glib::Object>() };
|
let obj = unsafe { $obj.unsafe_cast_ref::<$crate::glib::Object>() };
|
||||||
$crate::DebugCategory::log_unfiltered(
|
$crate::DebugCategory::log_unfiltered(
|
||||||
|
@ -707,7 +776,7 @@ macro_rules! log_with_level(
|
||||||
Some(obj),
|
Some(obj),
|
||||||
$level,
|
$level,
|
||||||
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
||||||
function_name.as_ref(),
|
$crate::glib::function_name!(),
|
||||||
line!(),
|
line!(),
|
||||||
format_args!($($args)*),
|
format_args!($($args)*),
|
||||||
)
|
)
|
||||||
|
@ -722,16 +791,7 @@ macro_rules! log_with_level(
|
||||||
use $crate::glib::Cast;
|
use $crate::glib::Cast;
|
||||||
|
|
||||||
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
||||||
// avoid this complication
|
// directly pass it as `&GStr` forward
|
||||||
let function_name = $crate::glib::function_name!();
|
|
||||||
let function_name_len = function_name.len();
|
|
||||||
let mut storage = [0u8; 256];
|
|
||||||
let function_name = if function_name_len < 256 {
|
|
||||||
storage[0..function_name_len].copy_from_slice(function_name.as_bytes());
|
|
||||||
::std::borrow::Cow::Borrowed(unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(&storage[..function_name_len+1]) })
|
|
||||||
} else {
|
|
||||||
::std::borrow::Cow::Owned($crate::glib::GString::from(function_name))
|
|
||||||
};
|
|
||||||
|
|
||||||
let obj = $imp.obj();
|
let obj = $imp.obj();
|
||||||
let obj = unsafe { obj.unsafe_cast_ref::<$crate::glib::Object>() };
|
let obj = unsafe { obj.unsafe_cast_ref::<$crate::glib::Object>() };
|
||||||
|
@ -746,7 +806,7 @@ macro_rules! log_with_level(
|
||||||
Some(obj),
|
Some(obj),
|
||||||
$level,
|
$level,
|
||||||
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
||||||
function_name.as_ref(),
|
$crate::glib::function_name!(),
|
||||||
line!(),
|
line!(),
|
||||||
$crate::glib::gstr!($msg),
|
$crate::glib::gstr!($msg),
|
||||||
)
|
)
|
||||||
|
@ -756,7 +816,7 @@ macro_rules! log_with_level(
|
||||||
Some(obj),
|
Some(obj),
|
||||||
$level,
|
$level,
|
||||||
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
||||||
function_name.as_ref(),
|
$crate::glib::function_name!(),
|
||||||
line!(),
|
line!(),
|
||||||
args,
|
args,
|
||||||
)
|
)
|
||||||
|
@ -772,16 +832,7 @@ macro_rules! log_with_level(
|
||||||
use $crate::glib::Cast;
|
use $crate::glib::Cast;
|
||||||
|
|
||||||
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
||||||
// avoid this complication
|
// directly pass it as `&GStr` forward
|
||||||
let function_name = $crate::glib::function_name!();
|
|
||||||
let function_name_len = function_name.len();
|
|
||||||
let mut storage = [0u8; 256];
|
|
||||||
let function_name = if function_name_len < 256 {
|
|
||||||
storage[0..function_name_len].copy_from_slice(function_name.as_bytes());
|
|
||||||
::std::borrow::Cow::Borrowed(unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(&storage[..function_name_len+1]) })
|
|
||||||
} else {
|
|
||||||
::std::borrow::Cow::Owned($crate::glib::GString::from(function_name))
|
|
||||||
};
|
|
||||||
|
|
||||||
let obj = $imp.obj();
|
let obj = $imp.obj();
|
||||||
let obj = unsafe { obj.unsafe_cast_ref::<$crate::glib::Object>() };
|
let obj = unsafe { obj.unsafe_cast_ref::<$crate::glib::Object>() };
|
||||||
|
@ -790,7 +841,7 @@ macro_rules! log_with_level(
|
||||||
Some(obj),
|
Some(obj),
|
||||||
$level,
|
$level,
|
||||||
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
||||||
function_name.as_ref(),
|
$crate::glib::function_name!(),
|
||||||
line!(),
|
line!(),
|
||||||
format_args!($($args)*),
|
format_args!($($args)*),
|
||||||
)
|
)
|
||||||
|
@ -803,16 +854,7 @@ macro_rules! log_with_level(
|
||||||
#[allow(clippy::redundant_closure_call)]
|
#[allow(clippy::redundant_closure_call)]
|
||||||
if $cat.above_threshold($level) {
|
if $cat.above_threshold($level) {
|
||||||
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
||||||
// avoid this complication
|
// directly pass it as `&GStr` forward
|
||||||
let function_name = $crate::glib::function_name!();
|
|
||||||
let function_name_len = function_name.len();
|
|
||||||
let mut storage = [0u8; 256];
|
|
||||||
let function_name = if function_name_len < 256 {
|
|
||||||
storage[0..function_name_len].copy_from_slice(function_name.as_bytes());
|
|
||||||
::std::borrow::Cow::Borrowed(unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(&storage[..function_name_len+1]) })
|
|
||||||
} else {
|
|
||||||
::std::borrow::Cow::Owned($crate::glib::GString::from(function_name))
|
|
||||||
};
|
|
||||||
|
|
||||||
// Check if formatting is necessary or not
|
// Check if formatting is necessary or not
|
||||||
// FIXME: This needs to be a closure because the return value of format_args!() can't
|
// FIXME: This needs to be a closure because the return value of format_args!() can't
|
||||||
|
@ -821,20 +863,20 @@ macro_rules! log_with_level(
|
||||||
if args.as_str().is_some() {
|
if args.as_str().is_some() {
|
||||||
$crate::DebugCategory::log_id_literal_unfiltered(
|
$crate::DebugCategory::log_id_literal_unfiltered(
|
||||||
$cat.clone(),
|
$cat.clone(),
|
||||||
Some($crate::glib::gstr!($id)),
|
$crate::glib::gstr!($id),
|
||||||
$level,
|
$level,
|
||||||
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
||||||
function_name.as_ref(),
|
$crate::glib::function_name!(),
|
||||||
line!(),
|
line!(),
|
||||||
$crate::glib::gstr!($msg),
|
$crate::glib::gstr!($msg),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
$crate::DebugCategory::log_id_unfiltered(
|
$crate::DebugCategory::log_id_unfiltered(
|
||||||
$cat.clone(),
|
$cat.clone(),
|
||||||
Some($crate::glib::gstr!($id)),
|
$crate::glib::gstr!($id),
|
||||||
$level,
|
$level,
|
||||||
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
||||||
function_name.as_ref(),
|
$crate::glib::function_name!(),
|
||||||
line!(),
|
line!(),
|
||||||
args,
|
args,
|
||||||
)
|
)
|
||||||
|
@ -848,23 +890,14 @@ macro_rules! log_with_level(
|
||||||
#[allow(unused_unsafe)]
|
#[allow(unused_unsafe)]
|
||||||
if $cat.above_threshold($level) {
|
if $cat.above_threshold($level) {
|
||||||
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
||||||
// avoid this complication
|
// directly pass it as `&GStr` forward
|
||||||
let function_name = $crate::glib::function_name!();
|
|
||||||
let function_name_len = function_name.len();
|
|
||||||
let mut storage = [0u8; 256];
|
|
||||||
let function_name = if function_name_len < 256 {
|
|
||||||
storage[0..function_name_len].copy_from_slice(function_name.as_bytes());
|
|
||||||
::std::borrow::Cow::Borrowed(unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(&storage[..function_name_len+1]) })
|
|
||||||
} else {
|
|
||||||
::std::borrow::Cow::Owned($crate::glib::GString::from(function_name))
|
|
||||||
};
|
|
||||||
|
|
||||||
$crate::DebugCategory::log_id_unfiltered(
|
$crate::DebugCategory::log_id_unfiltered(
|
||||||
$cat.clone(),
|
$cat.clone(),
|
||||||
Some($crate::glib::gstr!($id)),
|
$crate::glib::gstr!($id),
|
||||||
$level,
|
$level,
|
||||||
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
||||||
function_name.as_ref(),
|
$crate::glib::function_name!(),
|
||||||
line!(),
|
line!(),
|
||||||
format_args!($($args)*),
|
format_args!($($args)*),
|
||||||
)
|
)
|
||||||
|
@ -877,16 +910,7 @@ macro_rules! log_with_level(
|
||||||
#[allow(clippy::redundant_closure_call)]
|
#[allow(clippy::redundant_closure_call)]
|
||||||
if $cat.above_threshold($level) {
|
if $cat.above_threshold($level) {
|
||||||
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
||||||
// avoid this complication
|
// directly pass it as `&GStr` forward
|
||||||
let function_name = $crate::glib::function_name!();
|
|
||||||
let function_name_len = function_name.len();
|
|
||||||
let mut storage = [0u8; 256];
|
|
||||||
let function_name = if function_name_len < 256 {
|
|
||||||
storage[0..function_name_len].copy_from_slice(function_name.as_bytes());
|
|
||||||
::std::borrow::Cow::Borrowed(unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(&storage[..function_name_len+1]) })
|
|
||||||
} else {
|
|
||||||
::std::borrow::Cow::Owned($crate::glib::GString::from(function_name))
|
|
||||||
};
|
|
||||||
|
|
||||||
// Check if formatting is necessary or not
|
// Check if formatting is necessary or not
|
||||||
// FIXME: This needs to be a closure because the return value of format_args!() can't
|
// FIXME: This needs to be a closure because the return value of format_args!() can't
|
||||||
|
@ -895,20 +919,20 @@ macro_rules! log_with_level(
|
||||||
if args.as_str().is_some() {
|
if args.as_str().is_some() {
|
||||||
$crate::DebugCategory::log_id_literal_unfiltered(
|
$crate::DebugCategory::log_id_literal_unfiltered(
|
||||||
$cat.clone(),
|
$cat.clone(),
|
||||||
Some($id),
|
$id,
|
||||||
$level,
|
$level,
|
||||||
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
||||||
function_name.as_ref(),
|
$crate::glib::function_name!(),
|
||||||
line!(),
|
line!(),
|
||||||
$crate::glib::gstr!($msg),
|
$crate::glib::gstr!($msg),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
$crate::DebugCategory::log_id_unfiltered(
|
$crate::DebugCategory::log_id_unfiltered(
|
||||||
$cat.clone(),
|
$cat.clone(),
|
||||||
Some($id),
|
$id,
|
||||||
$level,
|
$level,
|
||||||
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
||||||
function_name.as_ref(),
|
$crate::glib::function_name!(),
|
||||||
line!(),
|
line!(),
|
||||||
args,
|
args,
|
||||||
)
|
)
|
||||||
|
@ -922,23 +946,14 @@ macro_rules! log_with_level(
|
||||||
#[allow(unused_unsafe)]
|
#[allow(unused_unsafe)]
|
||||||
if $cat.above_threshold($level) {
|
if $cat.above_threshold($level) {
|
||||||
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
||||||
// avoid this complication
|
// directly pass it as `&GStr` forward
|
||||||
let function_name = $crate::glib::function_name!();
|
|
||||||
let function_name_len = function_name.len();
|
|
||||||
let mut storage = [0u8; 256];
|
|
||||||
let function_name = if function_name_len < 256 {
|
|
||||||
storage[0..function_name_len].copy_from_slice(function_name.as_bytes());
|
|
||||||
::std::borrow::Cow::Borrowed(unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(&storage[..function_name_len+1]) })
|
|
||||||
} else {
|
|
||||||
::std::borrow::Cow::Owned($crate::glib::GString::from(function_name))
|
|
||||||
};
|
|
||||||
|
|
||||||
$crate::DebugCategory::log_id_unfiltered(
|
$crate::DebugCategory::log_id_unfiltered(
|
||||||
$cat.clone(),
|
$cat.clone(),
|
||||||
Some($id),
|
$id,
|
||||||
$level,
|
$level,
|
||||||
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
||||||
function_name.as_ref(),
|
$crate::glib::function_name!(),
|
||||||
line!(),
|
line!(),
|
||||||
format_args!($($args)*),
|
format_args!($($args)*),
|
||||||
)
|
)
|
||||||
|
@ -951,16 +966,7 @@ macro_rules! log_with_level(
|
||||||
#[allow(clippy::redundant_closure_call)]
|
#[allow(clippy::redundant_closure_call)]
|
||||||
if $cat.above_threshold($level) {
|
if $cat.above_threshold($level) {
|
||||||
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
||||||
// avoid this complication
|
// directly pass it as `&GStr` forward
|
||||||
let function_name = $crate::glib::function_name!();
|
|
||||||
let function_name_len = function_name.len();
|
|
||||||
let mut storage = [0u8; 256];
|
|
||||||
let function_name = if function_name_len < 256 {
|
|
||||||
storage[0..function_name_len].copy_from_slice(function_name.as_bytes());
|
|
||||||
::std::borrow::Cow::Borrowed(unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(&storage[..function_name_len+1]) })
|
|
||||||
} else {
|
|
||||||
::std::borrow::Cow::Owned($crate::glib::GString::from(function_name))
|
|
||||||
};
|
|
||||||
|
|
||||||
// Check if formatting is necessary or not
|
// Check if formatting is necessary or not
|
||||||
// FIXME: This needs to be a closure because the return value of format_args!() can't
|
// FIXME: This needs to be a closure because the return value of format_args!() can't
|
||||||
|
@ -972,7 +978,7 @@ macro_rules! log_with_level(
|
||||||
None as Option<&$crate::glib::Object>,
|
None as Option<&$crate::glib::Object>,
|
||||||
$level,
|
$level,
|
||||||
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
||||||
function_name.as_ref(),
|
$crate::glib::function_name!(),
|
||||||
line!(),
|
line!(),
|
||||||
$crate::glib::gstr!($msg),
|
$crate::glib::gstr!($msg),
|
||||||
)
|
)
|
||||||
|
@ -982,7 +988,7 @@ macro_rules! log_with_level(
|
||||||
None as Option<&$crate::glib::Object>,
|
None as Option<&$crate::glib::Object>,
|
||||||
$level,
|
$level,
|
||||||
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
||||||
function_name.as_ref(),
|
$crate::glib::function_name!(),
|
||||||
line!(),
|
line!(),
|
||||||
args,
|
args,
|
||||||
)
|
)
|
||||||
|
@ -996,23 +1002,14 @@ macro_rules! log_with_level(
|
||||||
#[allow(unused_unsafe)]
|
#[allow(unused_unsafe)]
|
||||||
if $cat.above_threshold($level) {
|
if $cat.above_threshold($level) {
|
||||||
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
// FIXME: Once there's a function_name! macro that returns a string literal we can
|
||||||
// avoid this complication
|
// directly pass it as `&GStr` forward
|
||||||
let function_name = $crate::glib::function_name!();
|
|
||||||
let function_name_len = function_name.len();
|
|
||||||
let mut storage = [0u8; 256];
|
|
||||||
let function_name = if function_name_len < 256 {
|
|
||||||
storage[0..function_name_len].copy_from_slice(function_name.as_bytes());
|
|
||||||
::std::borrow::Cow::Borrowed(unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(&storage[..function_name_len+1]) })
|
|
||||||
} else {
|
|
||||||
::std::borrow::Cow::Owned($crate::glib::GString::from(function_name))
|
|
||||||
};
|
|
||||||
|
|
||||||
$crate::DebugCategory::log_unfiltered(
|
$crate::DebugCategory::log_unfiltered(
|
||||||
$cat.clone(),
|
$cat.clone(),
|
||||||
None as Option<&$crate::glib::Object>,
|
None as Option<&$crate::glib::Object>,
|
||||||
$level,
|
$level,
|
||||||
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
unsafe { $crate::glib::GStr::from_utf8_with_nul_unchecked(concat!(file!(), "\0").as_bytes()) },
|
||||||
function_name.as_ref(),
|
$crate::glib::function_name!(),
|
||||||
line!(),
|
line!(),
|
||||||
format_args!($($args)*),
|
format_args!($($args)*),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue