| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/log_levels.R |
| 3 |
\name{colorize_levels} |
| 4 |
\alias{colorize_levels} |
| 5 |
\title{Colorize Levels} |
| 6 |
\usage{ |
| 7 |
colorize_levels( |
| 8 |
x, |
| 9 |
colors = getOption("lgr.colors", NULL), |
| 10 |
transform = identity |
| 11 |
) |
| 12 |
} |
| 13 |
\arguments{ |
| 14 |
\item{x}{\code{numeric} or \code{character} levels to be colored. Unlike in many other |
| 15 |
functions in lgr, \code{character} levels are \emph{not} case sensitive in this |
| 16 |
function and leading/trailing whitespace is ignored to make it more |
| 17 |
comfortable to use \code{colorize_levels()} inside formatting functions.} |
| 18 |
|
| 19 |
\item{colors}{A \code{list} of \code{functions} that will be used to color the |
| 20 |
log levels (likely from \link[crayon:crayon]{crayon::crayon}).} |
| 21 |
|
| 22 |
\item{transform}{a \code{function} to transform \code{x} (for example \code{toupper()})} |
| 23 |
} |
| 24 |
\value{ |
| 25 |
a \code{character} vector wit color ANSI codes |
| 26 |
} |
| 27 |
\description{ |
| 28 |
Colorize Levels |
| 29 |
} |
| 30 |
\examples{ |
| 31 |
cat(colorize_levels(c(100, 200))) |
| 32 |
cat(colorize_levels(c("trace", "warn ", "DEBUG"))) |
| 33 |
cat(colorize_levels(c("trace", "warn ", "DEBUG"), transform = function(x) strtrim(x, 1) )) |
| 34 |
} |
| 35 |
\seealso{ |
| 36 |
Other formatting utils: |
| 37 |
\code{\link{label_levels}()} |
| 38 |
} |
| 39 |
\concept{formatting utils} |