R/write_to_logfile.R

#' write a string of text to a log file
#' @param x string to write to file
#' @param .file file to write to
write_to_logfile <- function(x, .file) {
  if (!is.character(x) && length(x) == 1) {
    warning("cannot write anything but single character string to file")
    return(invisible())
  }
  .file <- file(.file, open = "a")
  on.exit(close(.file))
  writeLines(x, .file)
  invisible()
}
dpastoor/courier documentation built on May 15, 2019, 10:47 a.m.