diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-09-14 10:44:32 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-09-14 11:16:18 +0300 |
commit | 1a9fefcb34ff850ab6732feb8496893a47a5a6b2 (patch) | |
tree | 5b58d94ddd7ab488cba4c0283c2b083b1ef6bb12 /src/bin/subplot.rs | |
parent | 5e2ef34059fc424e650977a8e15deef00182e01e (diff) | |
download | subplot-1a9fefcb34ff850ab6732feb8496893a47a5a6b2.tar.gz |
debug: add tracing calls to help debug
I needed these to figure out a problem that wasn't in Subplot itself.
I'd like to keep them for the future.
Sponsored-by: author
Diffstat (limited to 'src/bin/subplot.rs')
-rw-r--r-- | src/bin/subplot.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/bin/subplot.rs b/src/bin/subplot.rs index 034cbb2..48406f1 100644 --- a/src/bin/subplot.rs +++ b/src/bin/subplot.rs @@ -8,7 +8,7 @@ use structopt::StructOpt; use subplot::{ generate_test_program, resource, template_spec, DataFile, Document, MarkupOpts, Style, }; -use tracing::{event, span, Level, Subscriber}; +use tracing::{event, instrument, span, Level, Subscriber}; use std::convert::TryFrom; use std::ffi::OsString; @@ -301,16 +301,23 @@ impl Docgen { self.input.parent() } + #[instrument(level = "trace", skip(self))] fn run(&self) -> Result<()> { let span = span!(Level::TRACE, "docgen"); let _enter = span.enter(); let mut style = Style::default(); if self.output.extension() == Some(&OsString::from("pdf")) { + event!(Level::TRACE, "PDF output chosen"); style.typeset_links_as_notes(); } let mut doc = cli::load_document(&self.input, style)?; + event!(Level::TRACE, "Got doc, now linting it"); doc.lint()?; - let template = doc.meta().template_name().unwrap_or("").to_string(); + event!(Level::TRACE, "Doc linted ok"); + let meta = doc.meta(); + event!(Level::TRACE, ?meta, "Looking for template"); + let template = meta.template_name().unwrap_or("").to_string(); + event!(Level::TRACE, ?template); if !doc.check_named_files_exist(&template)? || !doc.check_matched_steps_have_impl(&template) { eprintln!("Continuing despite warnings"); @@ -415,14 +422,18 @@ impl Codegen { .template_name() .ok_or_else(|| anyhow::anyhow!("No template name given"))? .to_string(); + event!(Level::TRACE, ?template); if !doc.check_named_files_exist(&template)? || !doc.check_matched_steps_have_impl(&template) { + event!(Level::ERROR, "Found problems in document, cannot continue"); eprintln!("Unable to continue"); std::process::exit(1); } + event!(Level::TRACE, "Generating code"); let spec = template_spec(&doc)?; generate_test_program(&mut doc, &spec, &self.output, &template)?; + event!(Level::TRACE, "Finished generating code"); if self.run { let run = match spec.run() { |