Make the tracing macros optional.
This commit is contained in:
@@ -12,6 +12,7 @@ use nom::combinator::recognize;
|
||||
use nom::combinator::verify;
|
||||
use nom::multi::many_till;
|
||||
use nom::sequence::terminated;
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing::span;
|
||||
|
||||
use super::radio_link::RematchObject;
|
||||
@@ -37,7 +38,7 @@ use crate::parser::StrikeThrough;
|
||||
use crate::parser::Underline;
|
||||
use crate::parser::Verbatim;
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn text_markup<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Object<'s>> {
|
||||
alt((
|
||||
map(parser_with_context!(bold)(context), Object::Bold),
|
||||
@@ -52,7 +53,7 @@ pub fn text_markup<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s
|
||||
))(input)
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn bold<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Bold<'s>> {
|
||||
let text_markup_object_specialized = text_markup_object("*");
|
||||
let (remaining, children) = text_markup_object_specialized(context, input)?;
|
||||
@@ -60,7 +61,7 @@ pub fn bold<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Bo
|
||||
Ok((remaining, Bold { source, children }))
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn italic<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Italic<'s>> {
|
||||
let text_markup_object_specialized = text_markup_object("/");
|
||||
let (remaining, children) = text_markup_object_specialized(context, input)?;
|
||||
@@ -68,7 +69,7 @@ pub fn italic<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
|
||||
Ok((remaining, Italic { source, children }))
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn underline<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Underline<'s>> {
|
||||
let text_markup_object_specialized = text_markup_object("_");
|
||||
let (remaining, children) = text_markup_object_specialized(context, input)?;
|
||||
@@ -76,7 +77,7 @@ pub fn underline<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st
|
||||
Ok((remaining, Underline { source, children }))
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn strike_through<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
@@ -87,7 +88,7 @@ pub fn strike_through<'r, 's>(
|
||||
Ok((remaining, StrikeThrough { source, children }))
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn verbatim<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Verbatim<'s>> {
|
||||
let text_markup_string_specialized = text_markup_string("=");
|
||||
let (remaining, contents) = text_markup_string_specialized(context, input)?;
|
||||
@@ -95,7 +96,7 @@ pub fn verbatim<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str
|
||||
Ok((remaining, Verbatim { source, contents }))
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn code<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Code<'s>> {
|
||||
let text_markup_string_specialized = text_markup_string("~");
|
||||
let (remaining, contents) = text_markup_string_specialized(context, input)?;
|
||||
@@ -110,7 +111,7 @@ fn text_markup_object(
|
||||
move |context: Context, input: &str| _text_markup_object(context, input, marker_symbol.as_str())
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn _text_markup_object<'r, 's, 'x>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
@@ -135,7 +136,9 @@ fn _text_markup_object<'r, 's, 'x>(
|
||||
)(remaining)?;
|
||||
|
||||
{
|
||||
#[cfg(feature = "tracing")]
|
||||
let span = span!(tracing::Level::DEBUG, "Checking parent exit.");
|
||||
#[cfg(feature = "tracing")]
|
||||
let _enter = span.enter();
|
||||
if exit_matcher_parser(context, remaining).is_ok() {
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||
@@ -156,7 +159,7 @@ fn text_markup_string(
|
||||
move |context: Context, input: &str| _text_markup_string(context, input, marker_symbol.as_str())
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn _text_markup_string<'r, 's, 'x>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
@@ -181,7 +184,9 @@ fn _text_markup_string<'r, 's, 'x>(
|
||||
))(remaining)?;
|
||||
|
||||
{
|
||||
#[cfg(feature = "tracing")]
|
||||
let span = span!(tracing::Level::DEBUG, "Checking parent exit.");
|
||||
#[cfg(feature = "tracing")]
|
||||
let _enter = span.enter();
|
||||
if exit_matcher_parser(context, remaining).is_ok() {
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||
@@ -195,7 +200,7 @@ fn _text_markup_string<'r, 's, 'x>(
|
||||
Ok((remaining, contents))
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn pre<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
||||
let document_root = context.get_document_root().unwrap();
|
||||
let preceding_character = get_one_before(document_root, input)
|
||||
@@ -215,7 +220,7 @@ pub fn pre<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()>
|
||||
Ok((input, ()))
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn post<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
||||
let (remaining, _) = alt((recognize(one_of(" \r\n\t-.,;:!?')}[\">")), line_ending))(input)?;
|
||||
Ok((remaining, ()))
|
||||
@@ -228,7 +233,7 @@ fn text_markup_end(
|
||||
move |context: Context, input: &str| _text_markup_end(context, input, marker_symbol.as_str())
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn _text_markup_end<'r, 's, 'x>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
@@ -244,7 +249,7 @@ fn _text_markup_end<'r, 's, 'x>(
|
||||
}
|
||||
|
||||
impl<'x> RematchObject<'x> for Bold<'x> {
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn rematch_object<'r, 's>(
|
||||
&'x self,
|
||||
_context: Context<'r, 's>,
|
||||
@@ -257,7 +262,7 @@ impl<'x> RematchObject<'x> for Bold<'x> {
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn _rematch_text_markup_object<'r, 's, 'x>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
@@ -279,7 +284,9 @@ fn _rematch_text_markup_object<'r, 's, 'x>(
|
||||
rematch_target(&parser_context, original_match_children, remaining)?;
|
||||
|
||||
{
|
||||
#[cfg(feature = "tracing")]
|
||||
let span = span!(tracing::Level::DEBUG, "Checking parent exit.");
|
||||
#[cfg(feature = "tracing")]
|
||||
let _enter = span.enter();
|
||||
if exit_matcher_parser(context, remaining).is_ok() {
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||
|
||||
Reference in New Issue
Block a user