Available log levels
Velo provides seven log levels, defined asLevel type in level.go:30-59:
Level hierarchy
Levels are ordered by severity from lowest to highest. When you set a minimum level, the logger only processes messages at that level or higher:- Setting
DebugLevellogs everything - Setting
InfoLevel(default) filters out debug messages - Setting
ErrorLevelonly logs errors and critical messages
Level serialization
JSON format
TheLevel.JSONField() method (level.go:65-83) returns a zero-allocation string for JSON serialization:
Text format
TheLevel.String() method (level.go:86-105) returns lowercase ASCII representations:
Parsing levels
Velo accepts both lowercase and uppercase level strings viaParseLevel() (level.go:154-158):
UnmarshalText() method (level.go:118-126) enables configuration via YAML, TOML, or JSON files:
Dynamic level adjustment
TheAtomicLevel type (level.go:165-167) allows you to safely change log levels at runtime across all goroutines without restarting your application.
Creating an atomic level
Changing levels at runtime
The
AtomicLevel.SetLevel() method (level.go:209-211) uses atomic operations to ensure thread-safe updates. All loggers referencing the same AtomicLevel immediately respect the new threshold.Checking if a level is enabled
Enabled() method (level.go:199-201) returns true if the specified level meets or exceeds the current minimum, allowing you to avoid expensive operations when logs would be discarded.
Special level
Velo internally usesnoLevel = 100 (level.go:58) for log entries that should not display a level field. This is an implementation detail not exposed in the public API.