1
0
mirror of https://gitlab.com/Anson-Projects/zine.git synced 2025-07-27 08:41:25 +00:00

Added proper logging

This commit is contained in:
2024-03-01 01:09:20 -07:00
parent 8b30cc58b9
commit 59b2fdef91
6 changed files with 113 additions and 16 deletions

View File

@@ -14,13 +14,15 @@ mod utilities;
mod web_fetchers;
fn main() -> Result<(), Box<dyn Error>> {
simple_logger::init_with_level(log::Level::Info).unwrap();
let featured = read_feed("featured_feeds.txt").first().unwrap().clone();
let mut entries = read_feed("feeds.txt");
// Move featured article to the front
entries.retain(|entry| entry != &featured);
entries.insert(0, featured);
println!(
log::info!(
"Featured article: {}",
entries[0].links.first().unwrap().href.as_str()
);
@@ -34,8 +36,8 @@ fn main() -> Result<(), Box<dyn Error>> {
.unwrap();
match write(output_path, index.into_string()) {
Ok(_) => println!("Successfully wrote to {}", output_path.display()),
Err(e) => eprintln!("Failed to write to {}: {}", output_path.display(), e),
Ok(_) => log::info!("Successfully wrote to {}", output_path.display()),
Err(e) => log::error!("Failed to write to {}: {}", output_path.display(), e),
}
Ok(())