Trace span events.
This commit is contained in:
parent
1fcb32d3c6
commit
cdb35edd64
@ -1,6 +1,7 @@
|
|||||||
use crate::parser::document;
|
use crate::parser::document;
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
use tracing::Level;
|
use tracing::Level;
|
||||||
|
use tracing_subscriber::fmt::format::FmtSpan;
|
||||||
|
|
||||||
mod parser;
|
mod parser;
|
||||||
|
|
||||||
@ -15,10 +16,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let subscriber = tracing_subscriber::fmt()
|
let subscriber = tracing_subscriber::fmt()
|
||||||
.event_format(format)
|
.event_format(format)
|
||||||
.with_max_level(Level::TRACE)
|
.with_max_level(Level::TRACE)
|
||||||
|
.with_span_events(FmtSpan::ENTER | FmtSpan::EXIT)
|
||||||
.finish();
|
.finish();
|
||||||
tracing::subscriber::set_global_default(subscriber)?;
|
tracing::subscriber::set_global_default(subscriber)?;
|
||||||
trace!("TESTING");
|
let parsed = document(TEST_DOC);
|
||||||
println!("{}\n\n\n", TEST_DOC);
|
println!("{}\n\n\n", TEST_DOC);
|
||||||
println!("{:#?}", document(TEST_DOC));
|
println!("{:#?}", parsed);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ use nom::multi::many1;
|
|||||||
use nom::multi::many_till;
|
use nom::multi::many_till;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
|
use tracing::instrument;
|
||||||
|
|
||||||
use super::nom_context::ContextTree;
|
use super::nom_context::ContextTree;
|
||||||
use super::nom_context::OrgModeContextTree;
|
use super::nom_context::OrgModeContextTree;
|
||||||
@ -137,6 +138,7 @@ pub fn paragraph_end(input: &str) -> Res<&str, &str> {
|
|||||||
recognize(tuple((map(line_break, TextElement::LineBreak), blank_line)))(input)
|
recognize(tuple((map(line_break, TextElement::LineBreak), blank_line)))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument]
|
||||||
pub fn document(input: &str) -> Res<&str, Vec<(Vec<TextElement>, &str)>> {
|
pub fn document(input: &str) -> Res<&str, Vec<(Vec<TextElement>, &str)>> {
|
||||||
let initial_context = ContextTree::new();
|
let initial_context = ContextTree::new();
|
||||||
let paragraph_context = initial_context.with_additional_fail_matcher(¶graph_end);
|
let paragraph_context = initial_context.with_additional_fail_matcher(¶graph_end);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user