Skip to content

Instantly share code, notes, and snippets.

@earino
Created August 23, 2016 18:59
Show Gist options
  • Save earino/ee737ed12e90caf739496d90e42565c5 to your computer and use it in GitHub Desktop.
Save earino/ee737ed12e90caf739496d90e42565c5 to your computer and use it in GitHub Desktop.
Replace the library() function so it logs
if (! "old_library" %in% ls()) {
old_library <- library
}
logging_library <- function(...) {
cat(as.character(substitute(...)),
sep="\n",
file="library_log.txt",
append=TRUE)
return(old_library(...))
}
library <- logging_library
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment