log

package
v0.2509.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogsDir

func GetLogsDir(dataDir string) string

GetLogsDir derives the path to the logs directory.

Types

type Log

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

Log is a log file handle.

It implements `io.Writer` so it can be used as the log handler and it also provides methods for streaming the content of the log.

func NewLog

func NewLog(fn string, maxSize int) (*Log, error)

NewLog creates a new log file handle.

Any existing file is truncated.

func (*Log) Close

func (l *Log) Close() error

Close closes the log file for writing.

func (*Log) Logger

func (l *Log) Logger() *logging.Logger

Logger returns a logger backed by this log file handle.

func (*Log) Read

func (l *Log) Read(ctx context.Context, opts WatchOptions) ([]string, error)

Read reads the lines from the log file using the given options, returning the read lines.

func (*Log) Watch

func (l *Log) Watch(ctx context.Context, ch chan<- string, opts WatchOptions) error

Watch starts watching the log file for changes, pushing lines to the passed channel.

func (*Log) Write

func (l *Log) Write(b []byte) (int, error)

Write writes the given buffer into the log file.

In case the total written size exceeds the configured maximum, the log file is rotated.

type Manager

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

Manager is a log manager.

func NewManager

func NewManager(dataDir string) *Manager

NewManager creates a new log manager.

func (*Manager) Get

func (m *Manager) Get(runtimeID common.Namespace, componentID component.ID) (*Log, error)

Get returns a log handle for the log of the given component.

func (*Manager) Remove

func (m *Manager) Remove(runtimeID common.Namespace, componentID component.ID)

Remove closes a log handle and removes any logs of the given component.

type WatchOptions

type WatchOptions struct {
	// Follow specifies whether to follow the log file for changes.
	Follow bool
	// Since specifies a time offset where to start from (excluding the offset itself).
	Since time.Time
}

WatchOptions are the watch options.

Jump to

Keyboard shortcuts

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