Skip to content

Commit 722b1d0

Browse files
authored
Merge pull request rstudio#2345 from rstudio/short_reactlog_labels
Shorter reactlog labels
2 parents 8b94d46 + 93d3b78 commit 722b1d0

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

R/graph.R

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ RLog <- R6Class(
237237
private$appendEntry(domain, list(
238238
action = "define",
239239
reactId = reactId,
240-
label = label,
240+
label = msg$shortenString(label),
241241
type = type,
242242
value = valueStr
243243
))
@@ -294,7 +294,7 @@ RLog <- R6Class(
294294
private$appendEntry(domain, list(
295295
action = "createContext",
296296
ctxId = ctxId,
297-
label = label,
297+
label = msg$shortenString(label),
298298
type = type,
299299
prevCtxId = prevCtxId,
300300
srcref = as.vector(attr(label, "srcref")), srcfile=attr(label, "srcfile")
@@ -511,12 +511,16 @@ MessageLogger = R6Class(
511511
if (identical(force, FALSE) && self$isNotLogging()) return(NULL)
512512
self$reactCache[[reactObj$reactId]] <- reactObj
513513
},
514-
shortenString = function(txt, n = 100) {
514+
shortenString = function(txt, n = 250) {
515+
if (is.null(txt) || isTRUE(is.na(txt))) {
516+
return("")
517+
}
515518
if (nchar(txt) > n) {
516-
paste0(substr(txt, 1, n - 3), "...")
517-
} else {
518-
txt
519+
return(
520+
paste0(substr(txt, 1, n - 3), "...")
521+
)
519522
}
523+
return(txt)
520524
},
521525
singleLine = function(txt) {
522526
gsub("[^\\]\\n", "\\\\n", txt)

0 commit comments

Comments
 (0)