add: logging
This commit is contained in:
parent
c798e387bd
commit
04ebd38691
4 changed files with 74 additions and 10 deletions
|
|
@ -4,12 +4,14 @@ use std::path::PathBuf;
|
|||
use typst::ecow::EcoString;
|
||||
use typst_as_lib::{typst_kit_options::TypstKitFontOptions, TypstEngine};
|
||||
use typst_html::{HtmlAttr, HtmlDocument, HtmlElement, HtmlNode};
|
||||
use log::info;
|
||||
|
||||
|
||||
pub fn compile_article(
|
||||
article_dir: &PathBuf,
|
||||
prepend: &Option<PathBuf>,
|
||||
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
info!("compiling {} ...", article_dir.display());
|
||||
|
||||
let template_file = article_dir.join("index.typ");
|
||||
let output = article_dir.join("index.html");
|
||||
|
|
@ -183,7 +185,6 @@ pub fn compile_all(
|
|||
compile_all(&path, prepend)?;
|
||||
} else if path.file_name().is_some_and(|n| n == "index.typ") {
|
||||
let dir = path.parent().unwrap().to_path_buf();
|
||||
println!("compiling {}", dir.display());
|
||||
compile_article(&dir, prepend)?;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use std::path::PathBuf;
|
|||
|
||||
use clap::Parser;
|
||||
use typssg::{compile_article, compile_all};
|
||||
use log::{info, error};
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
|
|
@ -17,9 +18,11 @@ struct Args {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
|
||||
match env::current_dir() {
|
||||
Ok(path) => println!("Current working directory: {}", path.display()),
|
||||
Err(e) => eprintln!("Error getting current directory: {}", e),
|
||||
Ok(path) => info!("Starting in working directory: {}", path.display()),
|
||||
Err(e) => error!("Error getting current directory: {}", e),
|
||||
}
|
||||
|
||||
let args = Args::parse();
|
||||
|
|
@ -31,7 +34,7 @@ fn main() {
|
|||
};
|
||||
|
||||
if let Err(e) = result {
|
||||
eprintln!("{e}");
|
||||
error!("{e}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue