Minimize str usage in rlog$valueStr (#2377)

* return early if loggin is disabled

* do not allow str to recurse

* add news item for #2377

* change "  " to " "

* Not a "world-ending performance issue"
This commit is contained in:
Barret Schloerke
2019-04-10 14:27:29 -04:00
committed by Joe Cheng
parent f6e8e645f2
commit a287ebe324
2 changed files with 8 additions and 1 deletions

View File

@@ -200,8 +200,13 @@ RLog <- R6Class(
},
valueStr = function(value, n = 200) {
if (!self$isLogging()) {
# return a placeholder string to avoid calling str
return("<reactlog is turned off>")
}
output <- try(silent = TRUE, {
utils::capture.output(utils::str(value))
# only capture the first level of the object
utils::capture.output(utils::str(value, max.level = 1))
})
outputTxt <- paste0(output, collapse="\n")
msg$shortenString(outputTxt, n = n)