msg {spsUtil} | R Documentation |
pretty logging message
Description
If
-
use_color = TRUE
or under SPS main package
use_crayon
option isTRUE
In a console that supports colors
Then the message will be colorful, other wise no color.
"INFO" level spawns message
, "WARNING" is warning
, "ERROR" spawns stop
,
other levels use cat
.
spsinfo
, spswarn
, spserror
are higher level wrappers of msg
. The
only difference is they have SPS-
prefix.
spsinfo
has an additional
arg verbose
. This arg works similarly to all other verbose
args in
SPS:
if not specified, it follows the project option. If SPS option
verbose
is set toTRUE
, message will be displayed; ifFALSE
, mute the message.It can be be forced to
TRUE
andFALSE
.TRUE
will forcibly generate the msg, andFALSE
will mute the message.
Usage
msg(
msg,
level = "INFO",
.other_color = NULL,
info_text = "INFO",
warning_text = "WARNING",
error_text = "ERROR",
use_color = TRUE
)
spsinfo(msg, verbose = NULL)
spswarn(msg)
spserror(msg)
Arguments
msg |
a character string of message or a vector of character strings, each item in the vector presents one line of words |
level |
typically, one of "INFO", "WARNING", "ERROR", not case sensitive. Other custom levels will work too. |
.other_color |
hex color code or named colors, when levels are not in "INFO", "WARNING", "ERROR", this value will be used |
info_text |
info level text prefix, use with "INFO" level |
warning_text |
warning level text prefix, use with "WARNING" level |
error_text |
error level text prefix, use with "ERROR" level |
use_color |
bool, default |
verbose |
bool, default get from sps project options, can be overwritten |
Details
If
use_color
isTRUE
, output message will forcibly use color if the console has color support, ignore SPSuse_crayon
option.If
use_color
isFALSE
, but you are using within SPS framework, theuse_crayon
option is set toTRUE
, color will be used.Otherwise message will be no color.
Value
see description and details
Examples
msg("this is info")
msg("this is warning", "warning")
try(msg("this is error", "error"))
msg("this is another level", "my level", "green")
spsinfo("some msg, verbose false", verbose = FALSE) # will not show up
spsinfo("some msg, verbose true", verbose = TRUE)
spswarn("sps warning")
try(spserror("sps error"))