logging

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuntimeLogAppenderZapRollingFile    = "zap_rolling_file"
	RuntimeEnvLogChannelRecord          = "record"
	RuntimeSuccessCommandOutputPolicy   = "suppressed"
	RuntimeFailureCommandOutputPolicy   = "included"
	RuntimeVerboseCommandOutputPolicy   = "details_on_verbose"
	RuntimeRecordCommandDiagnosticsMode = "preserved"
)

Variables

This section is empty.

Functions

func BuildLogger

func BuildLogger(verbose, debug bool) (*zap.Logger, error)

BuildLogger creates a zap.Logger with the appropriate verbosity level.

  • debug=true: Debug+ (implies verbose; development-style output)
  • verbose=true: Info+ (development-style output)
  • default: Warn+ (production-like)

Types

type Logger

type Logger interface {
	Debug(msg string, keysAndValues ...any)
	Info(msg string, keysAndValues ...any)
	Warn(msg string, keysAndValues ...any)
	Error(msg string, keysAndValues ...any)
	Verbose(msg string, keysAndValues ...any)
}

Logger is the logging interface accepted by the factory.

func EnsureLogger

func EnsureLogger(l Logger) Logger

EnsureLogger returns l if non-nil, otherwise returns a NoopLogger.

func NewZapLogger

func NewZapLogger(l *zap.Logger, verbose bool) Logger

NewZapLogger adapts a zap logger to the factory logging interface.

type NoopLogger

type NoopLogger struct{}

NoopLogger is a Logger that discards all log output. Used as the default when no logger is provided.

func (NoopLogger) Debug

func (NoopLogger) Debug(_ string, _ ...any)

func (NoopLogger) Error

func (NoopLogger) Error(_ string, _ ...any)

func (NoopLogger) Info

func (NoopLogger) Info(_ string, _ ...any)

func (NoopLogger) Verbose

func (NoopLogger) Verbose(_ string, _ ...any)

func (NoopLogger) Warn

func (NoopLogger) Warn(_ string, _ ...any)

type RuntimeLogConfig

type RuntimeLogConfig struct {
	// MaxSize sets the maximum size in megabytes of a log file before rotate.
	MaxSize int
	// MaxBackups controls how many backup files are retained.
	MaxBackups int
	// MaxAge controls how many days to retain backup files.
	MaxAge int
	// Compress enables gzip compression for rotated log files.
	Compress bool
}

RuntimeLogConfig controls rolling-file policy for the runtime logger. Values are in megabytes (MaxSize) and days (MaxAge).

func DefaultRuntimeLogConfig

func DefaultRuntimeLogConfig() RuntimeLogConfig

DefaultRuntimeLogConfig returns the production rolling-file policy used when callers do not set explicit runtime log limits.

type RuntimeLogSink

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

RuntimeLogSink owns the file-backed runtime logger and its rolling writer.

func BuildRuntimeLogger

func BuildRuntimeLogger(base *zap.Logger, runtimeInstanceID, runtimeLogDir string, config RuntimeLogConfig) (*RuntimeLogSink, error)

BuildRuntimeLogger creates a zap logger that writes runtime records to a bounded rolling JSON log file.

func (*RuntimeLogSink) Close

func (s *RuntimeLogSink) Close() error

Close releases the runtime log writer.

func (*RuntimeLogSink) Config

func (s *RuntimeLogSink) Config() RuntimeLogConfig

Config returns the normalized rolling-file policy applied to the sink.

func (*RuntimeLogSink) Logger

func (s *RuntimeLogSink) Logger() *zap.Logger

Logger returns the zap logger enriched with runtime logging fields and the rolling file core.

func (*RuntimeLogSink) Path

func (s *RuntimeLogSink) Path() string

Path returns the active runtime log path.

func (*RuntimeLogSink) RootDir added in v0.0.5

func (s *RuntimeLogSink) RootDir() string

RootDir returns the runtime log root selected by caller configuration or the default home-directory policy.

func (*RuntimeLogSink) StartTimeUTC added in v0.0.5

func (s *RuntimeLogSink) StartTimeUTC() time.Time

StartTimeUTC returns the UTC timestamp used to organize the active log path.

Jump to

Keyboard shortcuts

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