logger

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 8 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 logger in use.

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 logs to the file at logPath as well as to stdout. If the file cannot be opened, logging stays on stdout and Init returns the error.

func SetLevel added in v0.3.1

func SetLevel(l slog.Level)

SetLevel sets the lowest level logged.

func SetOutput

func SetOutput(w io.Writer)

SetOutput sends the log to w instead.

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