logger

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger added in v0.3.2

type Logger struct {
	// contains filtered or unexported fields
}

Logger wraps zerolog with file rotation and optional OTEL export. Create with New or Nop. Safe for concurrent use after construction.

func New added in v0.3.2

func New(opts Options) (*Logger, error)

New creates a logger with file output and optional OTEL bridge.

OTEL failure is non-fatal: the logger falls back to file-only and the OTEL warning is written to the log file.

func Nop added in v0.3.2

func Nop() *Logger

Nop returns a logger that discards all output.

func (*Logger) Close added in v0.3.2

func (l *Logger) Close() error

Close flushes pending OTEL batches and closes the file writer. Safe to call multiple times. Safe to call on a Nop logger.

func (*Logger) Debug added in v0.3.2

func (l *Logger) Debug() *zerolog.Event

Debug logs at debug level.

func (*Logger) Error added in v0.3.2

func (l *Logger) Error() *zerolog.Event

Error logs at error level.

func (*Logger) Fatal added in v0.3.2

func (l *Logger) Fatal() *zerolog.Event

Fatal logs at fatal level and exits. Avoid in Cobra hooks — return errors instead.

func (*Logger) Info added in v0.3.2

func (l *Logger) Info() *zerolog.Event

Info logs at info level.

func (*Logger) LogFilePath added in v0.3.2

func (l *Logger) LogFilePath() string

LogFilePath returns the path to the current log file, or empty string if this is a nop logger.

func (*Logger) Warn added in v0.3.2

func (l *Logger) Warn() *zerolog.Event

Warn logs at warn level.

func (*Logger) With added in v0.3.2

func (l *Logger) With(keyvals ...interface{}) *Logger

With returns a new Logger with additional context fields. Use this instead of per-call field injection for recurring context like project or agent.

projectLog := log.With("project", "foo", "agent", "bar")
projectLog.Info().Msg("started")

func (*Logger) Zerolog added in v0.3.2

func (l *Logger) Zerolog() zerolog.Logger

Zerolog returns the underlying zerolog.Logger for interop with libraries that accept one directly.

type Options added in v0.1.6

type Options struct {
	// LogsDir is the directory for log files. Required for file logging.
	LogsDir string

	// Filename overrides the log file name within LogsDir.
	// Defaults to "clawker.log" when empty.
	Filename string

	// File rotation settings.
	MaxSizeMB  int  // default: 50
	MaxAgeDays int  // default: 7
	MaxBackups int  // default: 3
	Compress   bool // default: true

	// Otel configures the OTEL zerolog bridge. Nil disables OTEL export.
	Otel *OtelOptions
}

Options configures the logger.

type OtelOptions added in v0.3.2

type OtelOptions struct {
	Endpoint       string        // e.g. "localhost:4318"
	Insecure       bool          // default: true (local collector)
	Timeout        time.Duration // export timeout
	MaxQueueSize   int           // batch processor queue size
	ExportInterval time.Duration // batch export interval
}

OtelOptions configures the OTLP HTTP log exporter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL