initializeLogging: Initialize Standard Log Files

Description Usage Arguments Value

Description

Convenience function that wraps logging initialization steps common to Mazama Science web services:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
result <- try({
  Copy and old log files
  timestamp <- strftime(lubridate::now(), "
  for ( logLevel in c("TRACE","DEBUG","INFO","ERROR") ) {
    oldFile <- file.path(logDir,paste0(logLevel,".log"))
    newFile <- file.path(logDir,paste0(logLevel,".log.",timestamp))
    if ( file.exists(oldFile) ) {
      file.rename(oldFile, newFile)
    }
  }
}, silent=TRUE)
stopOnError(result, "Could not rename old log files.")

result <- try({
  # Set up logging
  logger.setup(traceLog = file.path(logDir, "TRACE.log"),
               debugLog=file.path(logDir, "DEBUG.log"),
               infoLog=file.path(logDir, "INFO.log"),
               errorLog=file.path(logDir, "ERROR.log"))
}, silent=TRUE)
stopOnError(result, "Could not create log files.")

Usage

1

Arguments

logDir

directory in which to write log files

Value

No return value.


MazamaWebUtils documentation built on May 2, 2019, 2:41 a.m.