logscope

package
v1.1.17 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogScope

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

LogScope provides a scoped logger with memory buffering and optional forwarding to a parent logger. It creates an isolated logging environment that can capture log entries in memory while optionally forwarding them to a parent logger with inherited fields.

func NewLogger

func NewLogger(options *ScopeOptions) *LogScope

NewLogger creates a new LogScope with the specified options. If no options are provided, defaults to a buffer size of 100 entries. The logger discards output by default and relies on hooks for processing.

func (*LogScope) Flush

func (ls *LogScope) Flush()

Flush is a no-op method provided for interface compatibility. The LogScope uses hooks for immediate processing, so no flushing is needed.

func (*LogScope) GetLogEntries

func (ls *LogScope) GetLogEntries(from time.Time, limit int) []*logrus.Entry

GetLogEntries retrieves log entries from the memory buffer with optional filtering. The from parameter filters entries to those after the specified time (exclusive). The limit parameter restricts the number of returned entries (0 = no limit). Returns entries in chronological order, with older entries first.

func (*LogScope) GetLogEntryCount

func (ls *LogScope) GetLogEntryCount() int

GetLogEntryCount returns the total number of log entries processed by this scope. This includes entries that may have been rotated out of the memory buffer.

func (*LogScope) GetLogger

func (ls *LogScope) GetLogger() *logrus.Logger

GetLogger returns the underlying logrus logger instance. This logger has memory buffering and optional parent forwarding configured.

type ScopeOptions

type ScopeOptions struct {
	Parent     logrus.FieldLogger // Parent logger to forward entries to (optional)
	BufferSize uint64             // Maximum number of log entries to buffer in memory
}

ScopeOptions defines configuration for creating a LogScope instance. It specifies the parent logger for forwarding and buffer size for memory storage.

Jump to

Keyboard shortcuts

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