r-lib / debugme

Easy and efficient debugging for R packages
https://r-lib.github.io/debugme/
Other
149 stars 10 forks source link

added templating for debug #11

Closed mllg closed 7 years ago

mllg commented 7 years ago

I really like the idea of the package. I was just missing a way to include the value of variables in the output. Therefore I've patched debug() to retrieve variables for placeholders from the parent environment.

It should now be possible to do stuff like this:

path = file.path(tempdir())
ok = dir.create(file.path(path, "mydir"))
"!DEBUG Created directory {{path}}: {{ok}}"
"!DEBUG Files in {{path}}: {{length(list.files(path))}}"
gaborcsardi commented 7 years ago

Thanks!

It is not very well documented, but I actually implemented this already, almost the same way as you, but using backticks: https://github.com/gaborcsardi/debugme/blob/543ea249b3eb3fd0e2031ba93e44a24356ba1aaf/R/instrument.R#L31

mllg commented 7 years ago

Oh damn. I should RTFM first. I'll close then.

gaborcsardi commented 7 years ago

Or ask quickly, because I might be working on it already.... Hopefully it was not too much work....