use a filter to select debugging by level like Smart::Comment do
kforner opened this issue · 5 comments
Hi Gabor,
I have just discovered your package and I am already a big fan !
Do you know the Smart::Comment perl package ?
It uses the same kind of approach, using comments instead of string litterals (which you can not since R discards them in parsed code).
You set the level of the debugging by the number of '#', eg.
### is a level 1 debug
#### is a level2 debug
and you can select the debugging level at execution time using the Smart_Comment env var, e.g.
Smart_Comment=###:#### ./my_script.pl
which I think is nice since when you want to debug a script, you do not a priori know which packages it uses (can be indirect), so selecting the package via DEBUGME might not be the most convenient approach.
Maybe the syntax could be expanded like this:
DEBUGME=mypkg : turns on debugging for mypkg
DEBUGME=mypkg:1 turns on debugging level 1 for mypkg
DEBUGME=mypkg1:1,mypkg2:3
DEBUGME=1 turns on debugging level 1 for all packages
What do you think ?
Karl
I have just discovered your package and I am already a big fan !
Thanks!
Do you know the Smart::Comment perl package ?
It uses the same kind of approach, using comments instead of string litterals (which you can not since R discards them in parsed code).
Yeah, that's why I am using string literals.
You set the level of the debugging by the number of '#', eg.
### is a level 1 debug
#### is a level2 debug
and you can select the debugging level at execution time using the Smart_Comment env var, e.g.
Smart_Comment=###:#### ./my_script.pl
which I think is nice since when you want to debug a script, you do not a priori know which packages it uses (can be indirect), so selecting the package via DEBUG_ME might not be the most convenient approach.
What do you think ?
I thinks these are great ideas! AFAICT there are two possible improvements that we could make. One is setting the debug level of the messages, the way you propose. I would you exclamation marks, so that it is compatible with the current syntax:
"!DEBUG level 1"
...
"!!DEBUG level 2"
etc.
The other is auto-debugging. TBH I am not sure if this is useful enough in practice, because most packages do not use debugme
. But I can imagine two improvements for it:
- setting
DEBUGME="all"
would debug all packages (that supportdebugme
, obviously). Maybe we can also have an "all packages except these" syntax. - adding a function that queries which packages use
debugme
, so you'll have a rough idea what kind of messages to expect.
What do you think?
[I've updated my previous post]
I agree with the ! to indicate the debugging level.
as I wrote, maybe just DEBUGME=":1" to turn on debugging level 1 for all packages ?
Cool. Yeah, basically we just need to work out a good syntax now. I see your point about DEBUGME=":1"
. I like the explicit DEBUGME="all"
as well. So how about sg like this:
DEBUGME="pkg1,pkg2"
DEBUGME="!!pkg1,pkg2"
DEBUGME="all"
DEBUGME="!!!all"
DEBUGME="all,-except1,-except2"
DEBUGME="!!!all,-except1"
looks good !
OK, log levels are now supported. all
and the -package
notation are not yet. I'll open separate issues for those.