[librsvg: 13/45] rsvg_log_session!(): new macro, uses a Session to decide whether to log
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 13/45] rsvg_log_session!(): new macro, uses a Session to decide whether to log
- Date: Wed, 24 Aug 2022 01:56:37 +0000 (UTC)
commit e372e716f45aa31539ea01c50e9864d24e220567
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Aug 22 13:48:00 2022 -0500
rsvg_log_session!(): new macro, uses a Session to decide whether to log
We'll gradually replace calls to rsvg_log!() with this other macro,
and then rename all of them in a single shot.
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/731>
src/handle.rs | 3 ++-
src/log.rs | 12 ++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/src/handle.rs b/src/handle.rs
index 99827816b..e9d05e209 100644
--- a/src/handle.rs
+++ b/src/handle.rs
@@ -208,7 +208,8 @@ impl Handle {
.lookup_internal_node(&id)
.ok_or(DefsLookupErrorKind::NotFound),
NodeId::External(_, _) => {
- rsvg_log!(
+ rsvg_log_session!(
+ self.session,
"the public API is not allowed to look up external references: {}",
node_id
);
diff --git a/src/log.rs b/src/log.rs
index a8ec06142..4505e9737 100644
--- a/src/log.rs
+++ b/src/log.rs
@@ -13,6 +13,18 @@ macro_rules! rsvg_log {
};
}
+#[macro_export]
+macro_rules! rsvg_log_session {
+ (
+ $session:expr,
+ $($arg:tt)+
+ ) => {
+ if $session.log_enabled() {
+ println!("{}", format_args!($($arg)+));
+ }
+ };
+}
+
pub fn log_enabled() -> bool {
static ENABLED: Lazy<bool> = Lazy::new(|| ::std::env::var_os("RSVG_LOG").is_some());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]