Help us shape the future of Go! Take the 2026 Go Developer Survey

logger

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KindBackend keeps entries whose source does not start with "frontend".
	KindBackend = "backend"
	// KindFrontend keeps entries whose source starts with "frontend".
	KindFrontend = "frontend"
)

Variables

This section is empty.

Functions

func AppendWithTime

func AppendWithTime(ts time.Time, level, source, message string)

AppendWithTime records an externally supplied message while preserving the caller's timestamp. Used when replaying frontend logs whose clock may lead or lag the server. Used when replaying frontend logs whose clock may lead/lag the server.

func ClearBuffer

func ClearBuffer()

ClearBuffer drops every buffered backend + frontend entry.

func Debug

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

func Debugf

func Debugf(ctx context.Context, format string, args ...any)

func Error

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

func Errorf

func Errorf(ctx context.Context, format string, args ...any)

func Fatalf

func Fatalf(ctx context.Context, format string, args ...any)

func GetLevel

func GetLevel() string

GetLevel returns the current level as a lowercase string.

func Info

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

func Infof

func Infof(ctx context.Context, format string, args ...any)

func SetLevel

func SetLevel(name string) bool

SetLevel changes the global log level at runtime. Accepts the strings "debug", "info", "warn", "error" (case-insensitive). Unknown values leave the level unchanged and return false.

func Warn

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

func Warnf

func Warnf(ctx context.Context, format string, args ...any)

Types

type Entry

type Entry struct {
	ID        uint64    `json:"id"`
	Timestamp time.Time `json:"timestamp"`
	Level     string    `json:"level"`
	Source    string    `json:"source"`
	Message   string    `json:"message"`
}

Entry is a single log record captured by the in-memory ring buffer. It is exposed through the /api/v1/logs endpoint so the settings UI can show recent backend logs without having to tail stdout.

func RecentEntries

func RecentEntries(f Filter) []Entry

RecentEntries is the package-level accessor used by HTTP handlers.

type Filter

type Filter struct {
	MinLevel string
	Kind     string
	Sources  []string
	Since    uint64
	Limit    int
	Keyword  string
}

Filter narrows a RecentEntries query. A zero-value Filter returns everything the buffer still holds (newest first).

Kind partitions entries into the high-level "backend" / "frontend" buckets the settings UI exposes. Frontend entries are tagged with a "frontend" source prefix by the /api/v1/logs/frontend handler; everything else is treated as backend. Use Sources for exact-match component filtering.

Jump to

Keyboard shortcuts

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