log

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultSize   = 1024
	DefaultLog    = NewLog()
	DefaultFormat = TextFormat
)

Functions

func JSONFormat

func JSONFormat(r Record) string

func TextFormat

func TextFormat(r Record) string

Types

type FormatFunc

type FormatFunc func(Record) string

type Log

type Log interface {
	Read(...ReadOption) ([]Record, error)
	Write(Record) error
	Stream() (Stream, error)
}

func MemoryLog

func MemoryLog(opts ...Option) Log

NewLog returns default Logger with

func NewLog

func NewLog(opts ...Option) Log

func OsLog

func OsLog(opts ...Option) Log

type Option

type Option func(*Options)

Option used by the logger

func Format

func Format(f FormatFunc) Option

func Name

func Name(n string) Option

Name of the log

func Size

func Size(s int) Option

Size sets the size of the ring buffer

type Options

type Options struct {
	// Name of the log
	Name string
	// Size is the size of ring buffer
	Size int
	// Format specifies the output format
	Format FormatFunc
}

Options are logger options

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns default options

type ReadOption

type ReadOption func(*ReadOptions)

ReadOption used for reading the logs

func Count

func Count(c int) ReadOption

Count sets the number of log records to return

func Since

func Since(s time.Time) ReadOption

Since sets the time since which to return the log records

type ReadOptions

type ReadOptions struct {
	// Since what time in past to return the logs
	Since time.Time
	// Count specifies number of logs to return
	Count int
	// Stream requests continuous log stream
	Stream bool
}

ReadOptions for querying the logs

type Record

type Record struct {
	Timestamp time.Time         `json:"timestamp"`
	Metadata  map[string]string `json:"metadata"`
	Message   interface{}       `json:"proto"`
}

type Stream

type Stream interface {
	Chan() <-chan Record
	Stop() error
}

Jump to

Keyboard shortcuts

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