R/motusLog.R

#' Record messages to the motus main log.
#'
#' Works like sprintf, but sends output to the motus main log file,
#' after prepending the current date/time.  Output is followed by an
#' end-of-line.  If passed only a character vector, it is logged
#' with one item per line, with those after the first line indented.
#'
#' @param fmt character scalar \code{sprintf}-style formatting string
#' or character vector.
#'
#' @param ... any parameters required for \code{fmt}
#'
#' @return invisible(NULL)
#'
#' @export
#'
#' @author John Brzustowski \email{jbrzusto@@REMOVE_THIS_PART_fastmail.fm}

motusLog = function(fmt, ...) {
    if (length(list(...)) == 0) {
        out = paste(fmt, collapse="   \n")
    } else {
        out = sprintf(fmt, ...)
    }
    cat( format(Sys.time(), MOTUS_LOG_TIME_FORMAT),
        ": ",
        out,
        "\n",
        sep="",
        file = MOTUS_MAINLOG
        )
    invisible(NULL)
}
jbrzusto/motus-R-package documentation built on May 18, 2019, 7:03 p.m.