Documentation
¶
Overview ¶
Package log provides a leveled logger with emoji-rich console output for the iterion workflow engine.
Index ¶
- func BlockPreview(s string, max int) string
- func Truncate(s string, max int) string
- func TruncateMiddle(s string, max int) string
- type Level
- type Logger
- func (l *Logger) Debug(format string, args ...any)
- func (l *Logger) Error(format string, args ...any)
- func (l *Logger) Info(format string, args ...any)
- func (l *Logger) IsEnabled(level Level) bool
- func (l *Logger) Level() Level
- func (l *Logger) LogBlock(level Level, emoji string, header string, body string)
- func (l *Logger) Logf(level Level, emoji string, format string, args ...any)
- func (l *Logger) Trace(format string, args ...any)
- func (l *Logger) Warn(format string, args ...any)
- func (l *Logger) Writer() io.Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BlockPreview ¶
BlockPreview returns s truncated to max bytes, preserving newlines. If truncated, a "...[truncated]" marker is appended on a new line.
func Truncate ¶
Truncate returns s truncated to max bytes with a suffix if it exceeds max. Useful for limiting field sizes in log output and events.
func TruncateMiddle ¶
TruncateMiddle returns s shortened to at most max runes by replacing the middle with an ellipsis (…), keeping the beginning and the end. If s already fits in max runes it is returned unchanged. If max <= 0 an empty string is returned. The ellipsis itself counts as one rune toward the limit; when the remaining budget is odd the head receives the extra rune.
Unlike Truncate, which counts bytes, TruncateMiddle counts runes and always slices on rune boundaries — safe for arbitrary UTF-8 input such as IDs, hashes, paths, or URLs.
Types ¶
type Level ¶
type Level int
Level represents a logging verbosity level.
func ParseLevel ¶
ParseLevel converts a string to a Level. Case-insensitive. Returns LevelInfo if the string is empty.
func ResolveLevel ¶
ResolveLevel resolves the log level from explicit value, env var fallback, and default. The explicit value takes precedence over the env var.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a leveled logger that writes emoji-rich formatted output.
func (*Logger) LogBlock ¶
LogBlock logs a header line followed by a multi-line indented body block. The entire output is written in a single mutex-protected write to prevent interleaving from concurrent goroutines. If body is empty, only the header is printed.
func (*Logger) Logf ¶
Logf logs a pre-formatted message at the given level with a custom emoji prefix. This is useful when callers want to choose their own emoji.