Documentation
¶
Index ¶
- Constants
- func FromContext(ctx context.Context) *zerolog.Logger
- func GenerateSessionID() string
- func New(cfg Config) zerolog.Logger
- func NewFromConfigValues(level, format string) zerolog.Logger
- func NewFromConfigValuesWithTimeFormat(level, format, timeFormat string) zerolog.Logger
- func NewFromEnv() zerolog.Logger
- func NewWithFile(cfg Config, fileCfg FileConfig) (zerolog.Logger, func(), error)
- func ParseLevel(level string) zerolog.Level
- func ParseSessionFilename(filename string) (sessionID string, ok bool)
- func SessionFilename(sessionID string) string
- func ShortSessionID(sessionID string) string
- func With(ctx context.Context, fields map[string]any) context.Context
- func WithComponent(ctx context.Context, component string) context.Context
- func WithContext(ctx context.Context, logger zerolog.Logger) context.Context
- func WithPaneID(ctx context.Context, paneID string) context.Context
- func WithTabID(ctx context.Context, tabID string) context.Context
- func WithURL(ctx context.Context, url string) context.Context
- type Config
- type FileConfig
Constants ¶
const (
ConsoleTimeFormat = "15:04:05"
)
Variables ¶
This section is empty.
Functions ¶
func FromContext ¶ added in v0.20.0
FromContext extracts the logger from context If no logger is found, returns a disabled logger (no-op)
func GenerateSessionID ¶ added in v0.20.0
func GenerateSessionID() string
GenerateSessionID creates a unique session identifier. Format: YYYYMMDD_HHMMSS_xxxx (timestamp + 4 random hex chars) Example: 20251217_205106_a7b3
func NewFromConfigValues ¶ added in v0.20.0
NewFromConfigValues creates a logger from level and format strings. This is used by main.go to create a logger from the config package's LoggingConfig without creating an import cycle.
func NewFromConfigValuesWithTimeFormat ¶ added in v0.22.0
NewFromConfigValuesWithTimeFormat creates a logger from level/format and overrides time format.
func NewFromEnv ¶ added in v0.20.0
NewFromEnv creates a logger based on environment variables DUMBER_LOG_LEVEL: trace, debug, info, warn, error (default: info) DUMBER_LOG_FORMAT: json, console (default: console)
func NewWithFile ¶ added in v0.20.0
func NewWithFile(cfg Config, fileCfg FileConfig) (zerolog.Logger, func(), error)
NewWithFile creates a logger that writes to stderr and/or a session log file. The session file uses JSON format for easy parsing by the CLI logs command. LogDir must exist before calling this function (handled by config.EnsureDirectories). Returns the logger and a cleanup function to close the file.
func ParseLevel ¶ added in v0.20.0
ParseLevel converts a level string to zerolog.Level
func ParseSessionFilename ¶ added in v0.20.0
ParseSessionFilename extracts session info from a log filename. Example: "session_20251217_205106_a7b3.log" -> "20251217_205106_a7b3", true
func SessionFilename ¶ added in v0.20.0
SessionFilename generates the log filename for a session ID. Example: "20251217_205106_a7b3" -> "session_20251217_205106_a7b3.log"
func ShortSessionID ¶ added in v0.20.0
ShortSessionID extracts the short ID (last 4 hex chars) from a full session ID. Example: "20251217_205106_a7b3" -> "a7b3"
func With ¶ added in v0.20.0
With creates a child logger with additional fields and returns a new context
func WithComponent ¶ added in v0.20.0
WithComponent creates a child logger with a component field
func WithContext ¶ added in v0.20.0
WithContext returns a new context with the logger attached
func WithPaneID ¶ added in v0.20.0
WithPaneID creates a child logger with a pane_id field
Types ¶
type Config ¶ added in v0.20.0
Config holds logging configuration
func DefaultConfig ¶ added in v0.20.0
func DefaultConfig() Config
DefaultConfig returns sensible defaults