Skip to content

Helper function to shorten long strings when printing to logs. If the input string exceeds max characters, it is truncated and suffixed with "... (truncated)".

Usage

whapi_trunc(x, max = 2000L)

Arguments

x

A character string (or coercible to character).

max

Integer. Maximum number of characters to display (default: 2000).

Value

A character string, possibly truncated.

Examples

whapi_trunc("short text", max = 10)
#> [1] "short text"
whapi_trunc(paste(rep("a", 5000), collapse = ""), max = 20)
#> [1] "aaaaaaaaaaaaaaaaaaaa... (truncated)"