log

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func From

func From(ctx context.Context) log.Logger

From extracts a logger from the supplied context, or returns a NopLogger if none is found.

func Init added in v0.13.0

func Init(logLevel int, options ...InitOption) (log.LoggerCloser, error)

Init initializes a logger with options.

func NopLogger

func NopLogger() log.Logger

NopLogger constructs a nop logger

func WithLoggerContext

func WithLoggerContext(ctx context.Context, logger log.Logger) context.Context

WithLoggerContext returns a new context with a set logger

func Wrap

Wrap zap.SugaredLogger as Logger interface

Types

type EventStreamer added in v0.16.1

type EventStreamer interface {
	// Stream streams events.
	Stream(ready <-chan struct{}) (<-chan event.Event, func())
	// Close closes the streamer. No more events will be generated
	// one the streamer is closed.
	Close()
}

EventStreamer is an interface for streaming.

type InitOption added in v0.13.0

type InitOption func(config zap.Config) zap.Config

InitOption is a functional option for configuring a logger.

type ListenCancelFunc added in v0.16.0

type ListenCancelFunc func()

ListenCancelFunc is a function for canceling a sink listener.

type Message added in v0.16.0

type Message struct {
	// ID is the identifier for this log message.
	ID string
	// Date is the seconds since epoch.
	Date int64 `json:"date"`
	// LogLevel is the log level.
	LogLevel string `json:"logLevel"`
	// Location is the source location.
	Location string `json:"location"`
	// Text is the actual message.
	Text string `json:"text"`
	// JSON is the JSON payload.
	JSON string `json:"json"`
	// StackTrace is an optional stack trace.
	StackTrace string `json:"stackTrace"`
}

Message is an Octant log message.

func ConvertBytesToMessage added in v0.16.0

func ConvertBytesToMessage(b []byte, options ...Option) (Message, error)

ConvertBytesToMessage converts a zap message string to a Message instance.

type MessageIDGenerator added in v0.16.1

type MessageIDGenerator interface {
	Generate() string
}

MessageIDGenerator is an interface for generating message IDs.

type MessageListenerFactory added in v0.16.1

type MessageListenerFactory interface {
	// Listen creates a listener.
	Listen() (<-chan Message, ListenCancelFunc)
}

MessageListenerFactory is a factory which generates message listeners.

type OctantSink added in v0.16.0

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

OctantSink is an Octant log sink for zap. It creates a method that allows multiple loggers to listen to message.

func NewOctantSink added in v0.16.0

func NewOctantSink(options ...OctantSinkOption) *OctantSink

NewOctantSink creates an instance of OctantSink.

func (*OctantSink) Close added in v0.16.0

func (o *OctantSink) Close() error

Close closes the sink and its listeners.

func (*OctantSink) Listen added in v0.16.0

func (o *OctantSink) Listen() (<-chan Message, ListenCancelFunc)

Listen creates a channel for listening for messages and cancel func.

func (*OctantSink) Sync added in v0.16.0

func (o *OctantSink) Sync() error

Sync is a no-op as.

func (*OctantSink) Write added in v0.16.0

func (o *OctantSink) Write(p []byte) (n int, err error)

Write converts the message to a Message and sends it to all listeners. The message format is IS8061 date[\t]level[\t]location[\t]text[\t]optional payload[\n]

type OctantSinkOption added in v0.16.0

type OctantSinkOption func(o *OctantSink)

OctantSinkOption is an option for configuring OctantSink.

type Option added in v0.16.1

type Option func(o *options)

Option is a log option.

func WithIDGenerator added in v0.16.1

func WithIDGenerator(g MessageIDGenerator) Option

WithIDGenerator sets the message id generator option.

type Streamer added in v0.16.1

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

Streamer streams events using a ring buffer.

func NewStreamer added in v0.16.1

func NewStreamer(messageListenerFactory MessageListenerFactory) *Streamer

NewStreamer creates an instance of Streamer.

func (*Streamer) Close added in v0.16.1

func (lm *Streamer) Close()

Close closes the streamer.

func (*Streamer) Stream added in v0.16.1

func (lm *Streamer) Stream(readyCh <-chan struct{}) (<-chan event.Event, func())

Stream creates a channel which streams messages and a cancel function.

type UUIDMessageIDGenerator added in v0.16.1

type UUIDMessageIDGenerator struct{}

UUIDMessageIDGenerator generates messages IDs as UUIDs.

func (UUIDMessageIDGenerator) Generate added in v0.16.1

func (d UUIDMessageIDGenerator) Generate() string

Generate generates a UUID as a string.

Jump to

Keyboard shortcuts

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