Closed killercup closed 5 years ago
To avoid the need to add log
to the user's crate, log
should probably be re-exported from from-pest
conditionally. Honestly, I'm fine just adding log
support unconditionally, it's good to have and it's not like log
is going to significantly change the compile time of this procedural macro.
The problem with adding a "peer dependency" like this is that it'll break upstream crates using pest-ast
as well as the crate enabling the feature, so it's not purely additive.
Good idea about re-exporting log. It might be a bit tricky to get it right, though, as a single log::trace!(..)
expands to this:
{
let lvl = ::log::Level::Trace;
if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() {
::log::__private_api_log( fmt_args!(OMITTED) );
}
};
As you can see, it refers to a few items from log itself. I'll try to adapt the function I added to directly emit this code while replacing ::log::
with ::from_pest::
.
I'll still keep it behind a feature flag, just because it's no additional work; but I'll enable it by default.
Ah, nope, not necessary thanks to #[macro_export(local_inner_macros)]
!
This is a first step towards #9.
I had waaaay more logs in there but those were just for me to understand how this works. (Turns out, I just wrote
inner
where it should've saidouter
.)