Source-verified skills for the Charm terminal stack: Bubble Tea v2, Bubbles v2, Lip Gloss v2, Huh v2, Log v2, Glamour v2, plus the gum and vhs CLIs.
99
98%
Does it follow best practices?
Impact
100%
1.02xAverage score across 9 eval scenarios
Passed
No findings from the security scan
Constructors, setters, levels, and the Styles fields in Charm Log v2.0.1.
Return to the main skill for the workflow and examples.
log.Default(), used by log.Info and the other
package functions) writes to stderr at info level with timestamps; it is
built with ReportTimestamp: true.log.NewWithOptions(w, log.Options{...}) sets everything at once.log.New(w) is NewWithOptions(w, Options{}): info level, no prefix, and
no timestamp. Call SetReportTimestamp(true) on a custom logger if you
want the same look as the package logger.Setters exist for everything in Options:
SetLevel, SetPrefix, SetReportTimestamp, SetReportCaller,
SetTimeFormat, SetCallerOffset.SetTimeFunction: log.NowUTC for UTC stamps.SetCallerFormatter: ShortCallerFormatter or LongCallerFormatter.SetOutput: swaps the writer but keeps the color profile detected when
the logger was created.SetFormatter: TextFormatter, JSONFormatter, or LogfmtFormatter.SetStyles: takes a *Styles (below).SetColorProfile: takes a colorprofile.Profile from
github.com/charmbracelet/colorprofile.WithPrefix(p) returns a child with a new prefix; With(pairs...) returns a
child that carries fixed key value pairs. Helper() marks a function so the
caller shown is its caller.
DebugLevel, InfoLevel, WarnLevel, ErrorLevel, FatalLevel. Fatal
logs and calls os.Exit(1). Print ignores the level. ParseLevel("warn")
turns config text into a level. Every level function takes a message (any
value) followed by key value pairs; the f variants (Infof and so on)
take a format string instead.
Pass a logger through a context with log.WithContext(ctx, logger) and
recover it with log.FromContext(ctx) (falls back to the default logger).
log.DefaultStyles() returns a *Styles of Lip Gloss v2 values:
| Field | Holds |
|---|---|
Timestamp, Caller, Prefix, Message, Key, Value, Separator | one style each |
Levels | map by level; SetString on a level style changes the label text |
Keys, Values | maps by key name for per field overrides |