lgr (version 0.4.4)

colorize_levels: Colorize Levels

Description

Colorize Levels

Usage

colorize_levels(
  x,
  colors = getOption("lgr.colors", NULL),
  transform = identity
)

Value

a character vector wit color ANSI codes

Arguments

x

numeric or character levels to be colored. Unlike in many other functions in lgr, character levels are not case sensitive in this function and leading/trailing whitespace is ignored to make it more comfortable to use colorize_levels() inside formatting functions.

colors

A list of functions that will be used to color the log levels (likely from crayon::crayon).

transform

a function to transform x (for example toupper())

See Also

Other formatting utils: label_levels()

Examples

Run this code
cat(colorize_levels(c(100, 200)))
cat(colorize_levels(c("trace", "warn ", "DEBUG")))
cat(colorize_levels(c("trace", "warn ", "DEBUG"), transform = function(x) strtrim(x, 1) ))

Run the code above in your browser using DataLab