logging

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package logging configures Callee's zerolog and slog loggers.

Index

Constants

View Source
const (
	LevelTrace = "trace"
	LevelDebug = "debug"
	LevelInfo  = "info"
	LevelWarn  = "warn"
	LevelError = "error"
)

Variables

This section is empty.

Functions

func Init

func Init(setters ...Option) error

Init configures zerolog as Callee's logger and slog for dependencies.

func RoundElapsed added in v0.18.0

func RoundElapsed(duration time.Duration) time.Duration

RoundElapsed reduces elapsed telemetry to whole-second precision.

func WriteJSONError added in v0.6.0

func WriteJSONError(writer io.Writer, err error) error

WriteJSONError writes a command failure as one JSON Lines diagnostic event.

Types

type JSONLineWriter added in v0.6.0

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

JSONLineWriter wraps raw diagnostic lines in JSON Lines events.

func NewJSONLineWriter added in v0.6.0

func NewJSONLineWriter(writer io.Writer) *JSONLineWriter

NewJSONLineWriter returns an io.Writer that emits one event per input line.

func (*JSONLineWriter) Flush added in v0.6.0

func (w *JSONLineWriter) Flush() error

Flush emits the final unterminated line, if any.

func (*JSONLineWriter) Write added in v0.6.0

func (w *JSONLineWriter) Write(data []byte) (int, error)

Write buffers incomplete lines and emits completed diagnostic events.

type Option

type Option func(*options)

Option configures application logging.

func WithJSON

func WithJSON(enabled bool) Option

WithJSON writes JSON logs instead of human-readable console logs.

func WithLevel

func WithLevel(level string) Option

WithLevel selects trace, debug, info, warn, or error logging.

func WithWriter added in v0.6.0

func WithWriter(writer io.Writer) Option

WithWriter selects where logs are written. The default is standard error.

Jump to

Keyboard shortcuts

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