remove log crate (in favor of tracing)
All checks were successful
CI/CD Pipeline / test (push) Successful in 2m9s

This commit is contained in:
2024-02-27 15:24:39 +01:00
parent b4d464506c
commit 2f077a447c
10 changed files with 41 additions and 69 deletions

View File

@ -25,8 +25,6 @@ use std::{
path::Path,
};
use log::info;
use crate::{
law,
misc::{fetch_with_retries, get_cache_dir, Error},
@ -126,7 +124,6 @@ impl Parser {
/// );
/// ```
pub fn parse(&self, url: &str, builder: &mut law::Builder) -> Result<bool, Error> {
info!("Parsing {url}");
let xml = fetch(url)?;
let xml = xml.replace('\u{a0}', " ");
@ -193,7 +190,6 @@ fn fetch(url: &str) -> Result<String, Error> {
if let Ok(data) = fs::read_to_string(&expected_filename) {
Ok(data)
} else {
info!("Not finding url {url} in the cache, downloading...");
let data = fetch_with_retries(url)?;
let path = Path::new(&expected_filename);
if let Some(parent) = path.parent() {

View File

@ -16,7 +16,6 @@
use std::iter::Peekable;
use log::trace;
use roxmltree::{Children, Node};
use crate::law::Content;
@ -40,7 +39,6 @@ impl Absatz {
// - String: (optional) paragraph id
// - Content: content of the paragraph
pub(crate) fn parse_full(c: &mut Peekable<Children>) -> (Option<String>, Content) {
trace!("Parsing absatz...");
let absatz = AbsatzAbs::parse(c.next().unwrap());
let par_id = absatz.gldsym;
@ -50,7 +48,6 @@ impl Absatz {
// If there's a "liste" after an "absatz", the "liste" should be part of the "absatz"
while let Some(child) = c.peek() {
if Liste::test(child) {
trace!("Found liste inside absatz, parsing...");
let liste = Liste::parse_full(c).content;
content.extend(liste);
} else if Table::test(child) {

View File

@ -17,7 +17,6 @@
use std::collections::HashMap;
use std::iter::Peekable;
use log::{debug, trace};
use roxmltree::{Children, Node};
use crate::law;
@ -72,7 +71,6 @@ impl Abschnitt {
builder.new_par(par_id, Content::List(contents));
}
debug!("Handling post metadata");
ret.handle_metadata(&mut c, builder);
// Skip all UeberschriftTitle and Absatz
@ -103,7 +101,6 @@ impl Abschnitt {
// We are done with meta-data parsing
if key == "Text" {
trace!("Done parsing metadata, got 'Text'");
break;
}
@ -128,7 +125,6 @@ impl Abschnitt {
builder.add_next_para_note(value.clone());
}
trace!("Parsed metadata: key='{key}', value='{value}'");
self.metadata.insert(key, value);
}
}

View File

@ -16,7 +16,6 @@
use std::iter::Peekable;
use log::trace;
use roxmltree::{Children, Node};
use crate::{
@ -34,7 +33,6 @@ impl Liste {
}
pub(crate) fn parse_full(n: &mut Peekable<Children>) -> Self {
trace!("Parsing liste...");
Expect::from(n.peek().unwrap()).tag("liste");
let mut content = Vec::new();
@ -44,17 +42,12 @@ impl Liste {
// Parse stuff inside <liste>
while let Some(child) = c.peek() {
if Ziffernliste::test(child) {
trace!("Found Ziffernliste in liste, parsing...");
let liste = Ziffernliste::parse(&mut c);
content.push(liste.get_content());
} else if Schlussteil::test(child) {
// 162 Schifffahrtsgesetz show use that a 'schlussteil' can be at the start of a list
content.push(Content::Text(Schlussteil::parse(c.next().unwrap()).content));
} else {
trace!(
"No more acceptable element in the list found: '{}'",
child.tag_name().name()
);
break;
}
}

View File

@ -22,7 +22,6 @@ mod table;
use std::{fmt::Display, iter::Peekable};
use abschnitt::Abschnitt;
use log::trace;
use roxmltree::{Children, Node};
use crate::{
@ -117,7 +116,6 @@ impl Risdok {
pub(crate) fn from_str(xml: &str, builder: &mut law::Builder) -> Result<bool, Error> {
let doc = roxmltree::Document::parse(xml)?;
trace!("{doc:?}");
let root = doc.root();
assert_eq!(root.children().count(), 1);
Ok(Self::parse(root.children().next().unwrap(), builder))
@ -183,7 +181,6 @@ impl Listelem {
let text = c.next().unwrap().text().unwrap().into();
trace!("Parsed Listelem with text='{text}'");
Expect::empty(c.next());
Self { symbol, text }
@ -211,7 +208,6 @@ impl Ziffernliste {
}
pub(crate) fn parse(c: &mut Peekable<Children>) -> Self {
trace!("Parsing Ziffernliste...");
let n = c.next().unwrap();
assert!(Self::test(&n));