Documentation
¶
Index ¶
- Constants
- func FromContext(ctx context.Context) *zerolog.Logger
- func GenerateSessionID() string
- func InitStartupTrace(logLevel string)
- func InstallGLibLogHandler(ctx context.Context, logger zerolog.Logger, enableDebug bool)
- 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 TruncateURL(url string, maxLen int) 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
- type Milestone
- type StartupTrace
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 InitStartupTrace ¶ added in v0.26.0
func InitStartupTrace(logLevel string)
InitStartupTrace initializes the global startup trace. Call this as early as possible in main() to capture T0. The trace is enabled only if the given log level is debug or trace.
func InstallGLibLogHandler ¶ added in v0.26.0
InstallGLibLogHandler installs a custom GLib log handler that routes GTK4/WebKitGTK6/GLib messages to the provided zerolog logger. This must be called before GTK/WebKit initialization. The handler captures messages from all GLib-based libraries (GTK, GDK, WebKit, etc.) If enableDebug is true, GLib debug messages will also be captured (useful when log level is debug/trace).
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 TruncateURL ¶ added in v0.26.0
TruncateURL truncates a URL to maxLen characters for logging.
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
type FileConfig ¶ added in v0.20.0
type FileConfig struct {
Enabled bool
LogDir string
SessionID string
WriteToStderr bool // if false, logs go to file only (not stderr)
}
FileConfig holds file logging configuration
type Milestone ¶ added in v0.26.0
type Milestone struct {
Name string
Elapsed time.Duration // time since t0
Delta time.Duration // time since previous milestone
}
Milestone represents a timing checkpoint during startup.
type StartupTrace ¶ added in v0.26.0
type StartupTrace struct {
// contains filtered or unexported fields
}
StartupTrace tracks cold start milestones from process launch to first paint. Thread-safe for use across goroutines. Enabled only when log level is debug or trace.
func Trace ¶ added in v0.26.0
func Trace() *StartupTrace
Trace returns the global startup trace instance. Returns a no-op trace if not initialized or disabled.
func (*StartupTrace) Enabled ¶ added in v0.26.0
func (st *StartupTrace) Enabled() bool
Enabled returns whether the trace is active.
func (*StartupTrace) Finish ¶ added in v0.26.0
func (st *StartupTrace) Finish()
Finish marks the startup trace as complete and emits a summary. Called on first_paint milestone.
func (*StartupTrace) Mark ¶ added in v0.26.0
func (st *StartupTrace) Mark(name string)
Mark records a milestone with the given name. Emits a debug log line showing elapsed time and delta from previous milestone.
func (*StartupTrace) SetLogger ¶ added in v0.26.0
func (st *StartupTrace) SetLogger(logger *zerolog.Logger)
SetLogger sets the logger for emitting milestone logs. Flushes any buffered milestones that were recorded before the logger was set.
func (*StartupTrace) TotalElapsed ¶ added in v0.26.0
func (st *StartupTrace) TotalElapsed() time.Duration
TotalElapsed returns the total time since T0.
func (*StartupTrace) UpdateLogger ¶ added in v0.26.0
func (st *StartupTrace) UpdateLogger(logger *zerolog.Logger)
UpdateLogger updates the logger and re-emits all milestones to the new logger. Call this after the session file logger is available to capture milestones in the log file.