fertile
fertile copied to clipboard
Where should default log go?
How do we keep track of where the log file goes? At @jennybc 's suggestion I am using rprojroot
to find the project directory, but to return the working directory if find_root()
fails.
But if somebody just tries to use read_csv()
, we can't control whether they are in a project or what the working directory is at the time of the call. So to which log file should that event be written?
Symptom: devtools::test()
currently returns 0 errors, but devtools::check()
returns 3.
I think I don't understand enough about how fertile is put together and the context for "somebody just tries to use read_csv()
" to be helpful at this moment. But maybe it will be more clear after getting an intro in group meeting next week.
So there are at least two importantly different use cases here:
- In interactive mode, you might do:
library(tidyverse)
library(fertile)
read_csv("mydata.csv")
- In retrospective mode, you might do:
fertile::has_no_absolute_paths()
In the first case, the read_csv()
shim writes this action to a log file. But where is it? Well, by default it looks for the project root and puts it in the log file there.
In the second case, it's pointless to look at the same log file, because that file contains the actions the user made interactively. So we have to render the code in the project (using proj_render()
), all the while recording the user actions in a different (clean) log file. But how is the shimmed version of read_csv()
supposed to know which log file to write to? It can't be an option to fertile::read_csv()
(because no user is ever going to specify that location), so it has to be some kind of global variable.
Right??
So I'm wondering whether fertile
should explicitly maintain:
- a per-session log file (e.g.,
file_temp()
) - a persistent log file that lives in the project root (e.g., maybe just concatenate the per-session log files?)
- other per-session log files generated by
proj_render()
It's seems likely to me that this is an easy problem to solve, but I just don't understand sessions, environments, and global variables well enough at the moment.
The answer will help with #34.
I continue to not be immersed enough in fertile to have ready and great answers.
But I think another candidate location to have on your radar is ~/.R/fertile
, if you end up feeling like something should be recorded but has no natural and specific home.
@hadley agrees with @jennybc about keeping track of it in a .fertile
file somewhere.
Also, possible use Sys.setenv()
to keep track of it.