shtola

ssg in rust
git clone https://tilde.team/~marisa/repo/shtola.git
Log | Files | Refs | LICENSE

commit f774a339e1a5030d6ff9d3f162326ee8a3134fd5
parent 45bf7a260bf2258801f7b87d1c6982af37fd14f0
Author: marisa <mokou@posteo.de>
Date:   Wed, 27 Nov 2019 15:06:11 +0100

Add logging to shtola-markdown

Diffstat:
MCargo.lock | 1+
Mshtola-markdown/Cargo.toml | 3+++
Ashtola-markdown/examples/markdown.rs | 12++++++++++++
Mshtola-markdown/src/lib.rs | 4++++
4 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -442,6 +442,7 @@ name = "shtola-markdown" version = "0.1.0" dependencies = [ "comrak 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "pretty_env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "shtola 0.1.0", ] diff --git a/shtola-markdown/Cargo.toml b/shtola-markdown/Cargo.toml @@ -12,3 +12,6 @@ license-file = "LICENSE" [dependencies] comrak = "0.6.2" shtola = { path = "../shtola", version = "0.1.0" } + +[dev_dependencies] +pretty_env_logger = "0.3.1" diff --git a/shtola-markdown/examples/markdown.rs b/shtola-markdown/examples/markdown.rs @@ -0,0 +1,12 @@ +use shtola::Shtola; +use shtola_markdown::plugin as markdown; + +fn main() { + pretty_env_logger::init(); + let mut s = Shtola::new(); + s.source("fixtures/markdown"); + s.destination("fixtures/markdown/dest"); + s.clean(true); + s.register(markdown()); + s.build().unwrap(); +} diff --git a/shtola-markdown/src/lib.rs b/shtola-markdown/src/lib.rs @@ -1,9 +1,11 @@ use comrak::{markdown_to_html, ComrakOptions}; use shtola::{HashMap, Plugin, ShFile, IR}; +use shtola::log::{info, debug}; use std::path::PathBuf; pub fn plugin() -> Plugin { Box::new(|ir: IR| { + info!("Starting Markdown processing"); let markdown_files = ir .files .iter() @@ -11,6 +13,7 @@ pub fn plugin() -> Plugin { let mut update_hash: HashMap<PathBuf, ShFile> = HashMap::new(); let mut removal_hash: HashMap<PathBuf, ShFile> = HashMap::new(); for (path, file) in markdown_files { + debug!("Processing {:?}", &path); let mut p = path.clone(); p.set_extension("html"); removal_hash.insert(path.to_path_buf(), ShFile::empty()); @@ -26,6 +29,7 @@ pub fn plugin() -> Plugin { }, ); } + info!("Finished Markdown processing"); IR { files: update_hash.union(ir.files).difference(removal_hash), ..ir