Documentation
¶
Overview ¶
Package logging provides structured logging with charmbracelet/log.
Index ¶
- Constants
- func Close() error
- func Debug(msg string, keyvals ...interface{})
- func Debugf(format string, args ...interface{})
- func DryRun(msg string, keyvals ...interface{})
- func DryRunf(format string, args ...interface{})
- func Error(msg string, keyvals ...interface{})
- func Errorf(format string, args ...interface{})
- func GetLevel() clog.Level
- func Info(msg string, keyvals ...interface{})
- func Infof(format string, args ...interface{})
- func Init(cfg *config.Config) error
- func InitForTest(stdout, stderr io.Writer)
- func ResetForTest()
- func Result(msg string, keyvals ...interface{})
- func Resultf(format string, args ...interface{})
- func SetColors(enabled bool)
- func SetLevel(l clog.Level)
- func SetSensitiveEnvPrefixes(prefixes []string)
- func Status(msg string, keyvals ...interface{})
- func StatusPrefix() string
- func Statusf(format string, args ...interface{})
- func Verbose(msg string, keyvals ...interface{})
- func Verbosef(format string, args ...interface{})
- func Warn(msg string, keyvals ...interface{})
- func WarnFilef(format string, args ...interface{})
- func Warnf(format string, args ...interface{})
Constants ¶
const ( VerboseLevel clog.Level = -2 StatusLevel clog.Level = 1 ResultLevel clog.Level = 2 // DefaultLevel is the terminal log threshold in default mode (no flags). // At this level, Status (1) and Info (0) are suppressed on the terminal; // Result (2), DryRun (3), Warn (4), and Error (8) pass through. DefaultLevel clog.Level = 2 DryRunLevel clog.Level = 3 // SilentLevel suppresses all terminal output. Used for --quiet mode. // No messages are emitted at this level; it is only a threshold. SilentLevel clog.Level = 12 )
Custom log levels that fill gaps in charmbracelet/log's default level scheme. Levels < WarnLevel go to stdout; levels >= WarnLevel go to stderr.
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
func Debug(msg string, keyvals ...interface{})
Debug logs a debug message to stdout and file.
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf logs a formatted debug message.
func DryRun ¶
func DryRun(msg string, keyvals ...interface{})
DryRun logs a dry-run message to stdout and file.
func DryRunf ¶
func DryRunf(format string, args ...interface{})
DryRunf logs a formatted dry-run message.
func Error ¶
func Error(msg string, keyvals ...interface{})
Error logs an error message to stderr and file.
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs a formatted error message.
func Info ¶
func Info(msg string, keyvals ...interface{})
Info logs an info message to stdout and file.
func Init ¶
Init creates all loggers but does NOT set the terminal log level. Terminal level must be set separately via SetLevel() after all flag resolution is complete. Called from cmd/root.go PersistentPreRunE.
func InitForTest ¶
InitForTest creates loggers writing to the provided writers for test use. File logging is disabled. This allows tests to capture log output. Call ResetForTest in t.Cleanup to restore default loggers after the test.
func ResetForTest ¶
func ResetForTest()
ResetForTest restores loggers to default stdout/stderr writers. Use in t.Cleanup to prevent test logging state from leaking across tests.
func Result ¶ added in v0.8.0
func Result(msg string, keyvals ...interface{})
Result logs a result message to stdout and file.
func Resultf ¶ added in v0.8.0
func Resultf(format string, args ...interface{})
Resultf logs a formatted result message.
func SetColors ¶
func SetColors(enabled bool)
SetColors configures whether terminal loggers use color output. When NO_COLOR is set, enabling colors is a no-op to honor the convention.
func SetLevel ¶
SetLevel adjusts the terminal loggers' level. The file logger stays at Debug. The stdout logger level is set to the given level. The stderr logger level is always max(level, WarnLevel).
func SetSensitiveEnvPrefixes ¶
func SetSensitiveEnvPrefixes(prefixes []string)
SetSensitiveEnvPrefixes configures additional sensitive KEY prefixes that should be masked before writing to persistent file logs.
func Status ¶
func Status(msg string, keyvals ...interface{})
Status logs a status message to stdout and file.
func StatusPrefix ¶
func StatusPrefix() string
StatusPrefix returns the styled status prefix used by StatusLevel logs. The result is computed once and cached to avoid rebuilding the styles map on every status line render tick.
func Statusf ¶
func Statusf(format string, args ...interface{})
Statusf logs a formatted status message.
func Verbose ¶
func Verbose(msg string, keyvals ...interface{})
Verbose logs a verbose message to stdout and file.
func Verbosef ¶
func Verbosef(format string, args ...interface{})
Verbosef logs a formatted verbose message.
func Warn ¶
func Warn(msg string, keyvals ...interface{})
Warn logs a warning message to stderr and file.
Types ¶
This section is empty.