@@ -81,9 +81,8 @@ logger.error <- function(msg, ...) {
8181# #' This function will print a message and stop execution of the code. This
8282# #' should only be used if the application should terminate.
8383# #'
84- # #' set \code{\link{logger.setQuitOnSevere}(FALSE)} to avoid terminating
85- # #' the session. This is set by default to TRUE if interactive or running
86- # #' inside Rstudio.
84+ # #' Set \code{\link{logger.setQuitOnSevere}(FALSE)} to avoid terminating
85+ # #' the session. The default is to not quit if running interactively.
8786# #'
8887# #' @param msg the message that should be printed.
8988# #' @param ... any additional text that should be printed.
@@ -173,16 +172,28 @@ logger.message <- function(level, msg, ..., wrap = TRUE) {
173172# #' Configure logging level.
174173# #'
175174# #' This will configure the logger level. This allows to turn DEBUG, INFO,
176- # #' WARN and ERROR messages on and off.
175+ # #' WARN, ERROR, and SEVERE messages on and off.
176+ # #'
177+ # #' Note that this controls _printing_ of messages and does not change other behavior.
178+ # #' In particular, suppressing SEVERE by setting the level to "OFF" does not prevent
179+ # #' logger.severe() from signaling an error (and terminating the program if
180+ # #' `logger.setQuitOnSevere(TRUE)`).
181+ # #'
182+ # #' @param level the level of the message. One of "ALL", "DEBUG", "INFO", "WARN",
183+ # #' "ERROR", "SEVERE", or "OFF".
177184# #'
178- # #' @param level the level of the message (ALL, DEBUG, INFO, WARN, ERROR, OFF)
179185# #' @export
180186# #' @return When logger level is set, the previous level is returned invisibly.
181187# #' This can be passed to `logger.setLevel()` to restore the previous level.
182188# #' @author Rob Kooper
183189# #' @examples
184190# #' \dontrun{
185191# #' logger.setLevel('DEBUG')
192+ # #'
193+ # #' # Temporarily turn logger off
194+ # #' old_logger_level <- logger.setLevel("OFF")
195+ # #' # code here
196+ # #' logger.setLevel(old_logger_level)
186197# #' }
187198logger.setLevel <- function (level ) {
188199 original_level <- logger.getLevel()
@@ -193,14 +204,22 @@ logger.setLevel <- function(level) {
193204
194205
195206# # Given the string representation this will return the numeric value
196- # # DEBUG = 10
197- # # INFO = 20
198- # # WARN = 30
199- # # ERROR = 40
200- # # ALL = 99
201207# #
202- # #@return level the level of the message
203- # #@author Rob Kooper
208+ # # Supported levels
209+ # # ALL = 0
210+ # # DEBUG = 10
211+ # # INFO = 20
212+ # # WARN = 30
213+ # # ERROR = 40
214+ # # SEVERE = 50
215+ # # OFF = 60
216+ # #
217+ # # SEVERE is treated as more serious than ERROR,
218+ # # and will terminate the session if `logger.setQuitOnSevere(TRUE)`
219+ # # or call stop() otherwise
220+ # #
221+ # # @return level the level of the message
222+ # # @author Rob Kooper
204223logger.getLevelNumber <- function (level ) {
205224 if (toupper(level ) == " ALL" ) {
206225 return (0 )
@@ -213,7 +232,7 @@ logger.getLevelNumber <- function(level) {
213232 } else if (toupper(level ) == " ERROR" ) {
214233 return (40 )
215234 } else if (toupper(level ) == " SEVERE" ) {
216- return (40 )
235+ return (50 )
217236 } else if (toupper(level ) == " OFF" ) {
218237 return (60 )
219238 } else {
@@ -225,9 +244,14 @@ logger.getLevelNumber <- function(level) {
225244
226245# #' Get configured logging level.
227246# #'
228- # #' This will return the current level configured of the logging messages
247+ # #' This will return the current level configured of the logging messages.
248+ # #'
249+ # #' Note that `logger.setLevel()` invisibly returns current level, so
250+ # #' `logger.getLevel()` is not required to restore the level after a
251+ # #' temporary change.
229252# #'
230- # #' @return level the level of the message (ALL, DEBUG, INFO, WARN, ERROR, OFF)
253+ # #' @return A string giving the lowest message level that will be reported, one of
254+ # #' "ALL", "DEBUG", "INFO", "WARN", "ERROR", "SEVERE", or "OFF".
231255# #' @export
232256# #' @author Rob Kooper
233257# #' @examples
0 commit comments