Make the tracing macros optional.
This commit is contained in:
@@ -107,13 +107,13 @@ pub fn get_consumed<'s>(input: &'s str, remaining: &'s str) -> &'s str {
|
||||
/// A line containing only whitespace and then a line break
|
||||
///
|
||||
/// It is up to the caller to ensure this is called at the start of a line.
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn blank_line(input: &str) -> Res<&str, &str> {
|
||||
not(eof)(input)?;
|
||||
recognize(tuple((space0, alt((line_ending, eof)))))(input)
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn element_trailing_whitespace<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
@@ -122,7 +122,7 @@ pub fn element_trailing_whitespace<'r, 's>(
|
||||
alt((eof, recognize(many0(blank_line))))(input)
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn maybe_consume_trailing_whitespace_if_not_exiting<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
@@ -137,7 +137,7 @@ pub fn maybe_consume_trailing_whitespace_if_not_exiting<'r, 's>(
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn maybe_consume_trailing_whitespace<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
@@ -151,13 +151,13 @@ pub fn maybe_consume_trailing_whitespace<'r, 's>(
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn trailing_whitespace(input: &str) -> Res<&str, &str> {
|
||||
alt((eof, recognize(tuple((line_ending, many0(blank_line))))))(input)
|
||||
}
|
||||
|
||||
/// Check that we are at the start of a line
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn start_of_line<'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)
|
||||
@@ -178,7 +178,7 @@ pub fn start_of_line<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'
|
||||
}
|
||||
|
||||
/// Check that we are at the start of a line
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn preceded_by_whitespace<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
@@ -202,13 +202,13 @@ pub fn preceded_by_whitespace<'r, 's>(
|
||||
/// Pull one non-whitespace character.
|
||||
///
|
||||
/// This function only operates on spaces, tabs, carriage returns, and line feeds. It does not handle fancy unicode whitespace.
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn non_whitespace_character(input: &str) -> Res<&str, char> {
|
||||
none_of(" \t\r\n")(input)
|
||||
}
|
||||
|
||||
/// Check that we are at the start of a line
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn exit_matcher_parser<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
@@ -216,19 +216,19 @@ pub fn exit_matcher_parser<'r, 's>(
|
||||
peek(|i| context.check_exit_matcher(i))(input)
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn always_fail<'r, 's>(_context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||
Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||
"Always fail",
|
||||
))))
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn whitespace_eof(input: &str) -> Res<&str, &str> {
|
||||
recognize(tuple((multispace0, eof)))(input)
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn text_until_exit<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||
recognize(verify(
|
||||
many_till(anychar, parser_with_context!(exit_matcher_parser)(context)),
|
||||
|
||||
Reference in New Issue
Block a user