[librsvg: 43/45] Session: move the RSVG_LOG detection code to here




commit 3625293b6687ad2edf291c02b7ada674449eab3b
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Aug 23 20:39:29 2022 -0500

    Session: move the RSVG_LOG detection code to here
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/731>

 src/log.rs     | 8 --------
 src/session.rs | 8 +++++---
 2 files changed, 5 insertions(+), 11 deletions(-)
---
diff --git a/src/log.rs b/src/log.rs
index 03f6d07d8..952d8e6f2 100644
--- a/src/log.rs
+++ b/src/log.rs
@@ -1,7 +1,5 @@
 //! Utilities for logging messages from the library.
 
-use once_cell::sync::Lazy;
-
 #[macro_export]
 macro_rules! rsvg_log_session {
     (
@@ -14,12 +12,6 @@ macro_rules! rsvg_log_session {
     };
 }
 
-pub fn log_enabled() -> bool {
-    static ENABLED: Lazy<bool> = Lazy::new(|| ::std::env::var_os("RSVG_LOG").is_some());
-
-    *ENABLED
-}
-
 /// Captures the basic state of a [`cairo::Context`] for logging purposes.
 ///
 /// A librsvg "transaction" like rendering a
diff --git a/src/session.rs b/src/session.rs
index 1f2b998b0..fe556cef2 100644
--- a/src/session.rs
+++ b/src/session.rs
@@ -2,8 +2,6 @@
 
 use std::sync::Arc;
 
-use crate::log;
-
 /// Metadata for a loading/rendering session.
 ///
 /// When the calling program first uses one of the API entry points (e.g. `Loader::new()`
@@ -18,11 +16,15 @@ struct SessionInner {
     log_enabled: bool,
 }
 
+fn log_enabled_via_env_var() -> bool {
+    ::std::env::var_os("RSVG_LOG").is_some()
+}
+
 impl Default for Session {
     fn default() -> Self {
         Self {
             inner: Arc::new(SessionInner {
-                log_enabled: log::log_enabled(),
+                log_enabled: log_enabled_via_env_var(),
             }),
         }
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]