[librsvg: 16/45] xml/mod.rs: Use a session for logging




commit 2f8c13263c45760ae92f8c9ab2c10031da18157f
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Aug 22 15:41:05 2022 -0500

    xml/mod.rs: Use a session for logging
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/731>

 src/xml/mod.rs | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/src/xml/mod.rs b/src/xml/mod.rs
index 8a6c7ed40..7fb4e147e 100644
--- a/src/xml/mod.rs
+++ b/src/xml/mod.rs
@@ -268,6 +268,8 @@ impl XmlState {
 
             let mut inner = self.inner.borrow_mut();
 
+            let session = inner.document_builder.as_mut().unwrap().session().clone();
+
             if let Some(href) = href {
                 // FIXME: https://www.w3.org/TR/xml-stylesheet/ does not seem to specify
                 // what to do if the stylesheet cannot be loaded, so here we ignore the error.
@@ -278,13 +280,17 @@ impl XmlState {
                     .append_stylesheet_from_xml_processing_instruction(alternate, type_, &href)
                     .is_err()
                 {
-                    rsvg_log!(
+                    rsvg_log_session!(
+                        session,
                         "invalid xml-stylesheet {} in XML processing instruction",
                         href
                     );
                 }
             } else {
-                rsvg_log!("xml-stylesheet processing instruction does not have href; ignoring");
+                rsvg_log_session!(
+                    session,
+                    "xml-stylesheet processing instruction does not have href; ignoring"
+                );
             }
         } else {
             self.error(LoadingError::XmlParseError(String::from(
@@ -477,6 +483,15 @@ impl XmlState {
         encoding: Option<&str>,
     ) -> Result<(), AcquireError> {
         if let Some(href) = href {
+            let session = self
+                .inner
+                .borrow()
+                .document_builder
+                .as_ref()
+                .unwrap()
+                .session()
+                .clone();
+
             let aurl = self
                 .inner
                 .borrow()
@@ -487,7 +502,7 @@ impl XmlState {
                 .map_err(|e| {
                     // FIXME: should AlloweUrlError::UrlParseError be a fatal error,
                     // not a resource error?
-                    rsvg_log!("could not acquire \"{}\": {}", href, e);
+                    rsvg_log_session!(session, "could not acquire \"{}\": {}", href, e);
                     AcquireError::ResourceError
                 })?;
 
@@ -517,8 +532,17 @@ impl XmlState {
     }
 
     fn acquire_text(&self, aurl: &AllowedUrl, encoding: Option<&str>) -> Result<(), AcquireError> {
+        let session = self
+            .inner
+            .borrow()
+            .document_builder
+            .as_ref()
+            .unwrap()
+            .session()
+            .clone();
+
         let binary = io::acquire_data(aurl, None).map_err(|e| {
-            rsvg_log!("could not acquire \"{}\": {}", aurl, e);
+            rsvg_log_session!(session, "could not acquire \"{}\": {}", aurl, e);
             AcquireError::ResourceError
         })?;
 


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