https://github.com/moodymudskipper/liblog
Log Calls to loadNamespace
https://github.com/moodymudskipper/liblog
Last synced: 3 months ago
JSON representation
Log Calls to loadNamespace
- Host: GitHub
- URL: https://github.com/moodymudskipper/liblog
- Owner: moodymudskipper
- Created: 2020-02-25T14:34:58.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-25T20:48:27.000Z (almost 5 years ago)
- Last Synced: 2024-08-13T07:15:00.953Z (6 months ago)
- Language: R
- Size: 7.81 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
- jimsghstars - moodymudskipper/liblog - Log Calls to loadNamespace (R)
README
---
output: github_document
---[](https://travis-ci.org/moodymudskipper/liblog)
[](https://codecov.io/gh/moodymudskipper/liblog?branch=master)```{r, include = FALSE}
knitr::opts_chunk$set(
eval=FALSE,
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# liblog
This package logs calls to loadNamespace, so one can track thei use of packages.
Install with:
``` r
remotes::install_github("moodymudskipper/liblog")
```## Suggested use
Edit your R profile, (you can run `file.edit(file.path(R.home(), "etc", "RProfile.site"))`)
and add the following line at the end :```{r}
liblog::use_liblog()
```It will display the following message each time you start R:
> Tracing function "loadNamespace" in package "base"
> to log loaded namespaces in 'C:/PROGRA~1/R/R-36~1.2/loadNamespace.log'The actual path will change depending on your system.
If you'd rather do it silently, use `liblog::use_liblog(verbose = FALSE)` instead.
From there on, each time a package has its namespace loaded (not only attached!),
a new line will be added to the file mentionned in the message, you can get
this path by calling `getOption("liblog.path")` and you can choose another path
by adding a call to `options()` before `use_liblog()` call in your RProfile
so you'll have:```{r}
options(liblog.path = your_path)
liblog::use_liblog()
```## Test it!
Apply the steps above, restart R (in RStudio : ctrl + shift + F10), then
see what's been logged already by calling :```{r}
file.edit(getOption("liblog.path"))
```Duplicates are present because `loadNamespace()` is really called several times
on some packages.More conveniently, you can call `liblog::get_liblog()`, which by default removes
duplicate records and ignores base and recommended packages.## Is that it ?
For now it is, after I've used it for some time I think I'll implement some
visualization functions wrapped on `get_liblog()`. Maybe I'll also need some
options or utilisties to flush or archive the log, or warn about it getting too big,
but I need data first! (or feedback, wink wink => POST ISSUES AND HELP ME HELP YOU!).