logger

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package logger provides the plugin's structured logging and rotating log files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debugf

func Debugf(format string, args ...any)

Debugf logs at debug level with printf-style formatting.

func Errorf

func Errorf(format string, args ...any)

Errorf logs at error level with printf-style formatting.

func Get

func Get() *slog.Logger

Get returns the global logger, initializing with defaults if needed.

func Infof

func Infof(format string, args ...any)

Infof logs at info level with printf-style formatting.

func Init

func Init(logPath string) error

Init initializes the global logger with file and stdout output. Call this once at startup. If not called, Get() will initialize with defaults.

func SetOutput

func SetOutput(w io.Writer)

SetOutput sends the log to w instead, for tests.

func Warnf

func Warnf(format string, args ...any)

Warnf logs at warn level with printf-style formatting.

func With

func With(args ...any) *slog.Logger

With returns a logger with additional attributes.

Types

type RotatingFile

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

RotatingFile is an append-only log file that is renamed to <path>.1 once it would grow past maxBytes, so a log never takes more than twice that on disk.

func OpenRotating

func OpenRotating(path string, maxBytes int64) (*RotatingFile, error)

OpenRotating opens or creates the log file at path.

func (*RotatingFile) Close

func (r *RotatingFile) Close() error

Close closes the file.

func (*RotatingFile) Write

func (r *RotatingFile) Write(p []byte) (int, error)

Write appends p, rotating first if p would take the file past its limit.

Jump to

Keyboard shortcuts

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