Skip to contents

Set the active glyph/color theme

Usage

logtree_theme(
  theme = c("unicode", "ascii", "emoji"),
  overrides = list(),
  compact = FALSE
)

Arguments

theme

Either a preset name ("unicode", "ascii", "emoji") to swap the whole glyph set, or a named list of per-key overrides to merge onto the currently active theme (matching the two calling styles shown in the package documentation).

overrides

A named list of per-key overrides applied on top of theme after it is resolved. Each entry may specify glyph, width, and/or color; unspecified fields are kept from the existing entry. The group slot also accepts bracket (logical, default FALSE): when TRUE the header name is wrapped in < >.

compact

Density of the tree's per-level indentation. FALSE (the default) keeps the normal spacing (three columns per level in the unicode theme); "medium" drops the trailing gap after each connector (two columns per level); "tight" additionally slims the branch and corner connectors to a single character (one column per level). TRUE is an alias for "tight". Compact applies to the active (console) theme and is cleared by a subsequent preset swap such as logtree_theme("unicode").

Value

NULL, invisibly.

Details

An override list is keyed by slot; each slot's value is itself a named list of fields. Only the fields you name are changed – everything else is kept from the active theme.

Slots (valid names in an override / preset list):

SlotApplies toFields it accepts
stepopen / running step glyphglyph, width, color
infolog_info() leafglyph, width, color
debuglog_debug() leafglyph, width, color
successsuccess glyph (clean close, log_success())glyph, width, color
warninglog_warn() / elevated step glyphglyph, width, color
errorlog_error() / elevated step glyphglyph, width, color
interruptedabnormal-exit (dimmed) glyphglyph, width, color
groupgroup header markerglyph, color, bracket
branchchild connector: the "tee" drawn before every child lineglyph, color
cornerclose-line connector: the "elbow" drawn on a step's own close lineglyph, color
pipevertical rail carried down the left of nested linesglyph, color

Fields (valid names inside a slot):

FieldTypeAccepted values
glyphcharacter(1)Any string, including "". In package source, non-ASCII must be written as \u/\U escapes, never literal characters.
widthinteger(1)Rendered display width of glyph (1 for normal, 2 for emoji / wide cells). Drives column alignment and cannot be measured, so set it to the true width. Status slots only (step, info, debug, success, warning, error, interrupted).
colorcharacter or NULLOne or more cli styles, or NULL for no styling. Named colors ("red", "cyan", "silver", ...), bright variants ("br_red"), backgrounds ("bg_blue"), text styles ("bold", "italic", "dim"), or a hex string ("#ff8800"). A character vector combines styles, e.g. c("red", "bold"). See cli::combine_ansi_styles().
bracketlogical(1)group slot only. TRUE wraps the header name in < >; default FALSE.

Examples

logtree_theme("ascii")
logtree_theme("unicode")
logtree_theme(overrides = list(success = list(glyph = "*")))
logtree_theme(overrides = list(group = list(glyph = "#", bracket = TRUE)))
logtree_theme("unicode", compact = "medium")
logtree_theme("unicode", compact = "tight")
logtree_theme("unicode")