summaryrefslogtreecommitdiff
path: root/src/doc.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-04-15 10:58:51 +0300
committerLars Wirzenius <liw@liw.fi>2022-04-15 17:24:09 +0300
commit884b4a78114a931bea52941a614985a44ddd92db (patch)
treeb65b63122d4376b0745ebd377bfa445ba2b49fcb /src/doc.rs
parent60277d108b1aab5b9bc658118427aea944cbd301 (diff)
downloadsubplot-884b4a78114a931bea52941a614985a44ddd92db.tar.gz
feat: improve logging via env_logger
Configure env_logger from environment, including style (colors). Simplify how log messages are formatted: drop the timestamp and crate name, as they're just noise for the case of Subplot. Adjust log messages so that what a user may want to normally know is info or above, and at level debug if they want to see in more detail what's happening. Handle the error from failing to execute pandoc specially, for a better error message. The default error message from the pandoc crate was hard for a user to understand. The new message clearly says what the exit code is, and logs the stderr, but not stdout, as Pandoc correctly writes errors only to stderr. Sponsored-by: author
Diffstat (limited to 'src/doc.rs')
-rw-r--r--src/doc.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/doc.rs b/src/doc.rs
index 89b9eea..9c5fae8 100644
--- a/src/doc.rs
+++ b/src/doc.rs
@@ -532,7 +532,13 @@ where
/// Generate code for one document.
pub fn codegen(filename: &Path, output: &Path, template: Option<&str>) -> Result<CodegenOutput> {
- let mut doc = load_document_with_pullmark(filename, Style::default(), template)?;
+ let r = load_document_with_pullmark(filename, Style::default(), template);
+ let mut doc = match r {
+ Ok(doc) => doc,
+ Err(err) => {
+ return Err(err);
+ }
+ };
doc.lint()?;
let template = template
.map(Ok)
@@ -547,7 +553,6 @@ pub fn codegen(filename: &Path, output: &Path, template: Option<&str>) -> Result
|| !doc.check_embedded_files_are_used(&template)?
{
error!("Found problems in document, cannot continue");
- eprintln!("Unable to continue");
std::process::exit(1);
}