Documentation ¶
Index ¶
- func From(ctx context.Context) log.Logger
- func Init(logLevel int, options ...InitOption) (log.LoggerCloser, error)
- func NopLogger() log.Logger
- func WithLoggerContext(ctx context.Context, logger log.Logger) context.Context
- func Wrap(z *zap.SugaredLogger) log.LoggerCloser
- type EventStreamer
- type InitOption
- type ListenCancelFunc
- type Message
- type MessageIDGenerator
- type MessageListenerFactory
- type OctantSink
- type OctantSinkOption
- type Option
- type Streamer
- type UUIDMessageIDGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func From ¶
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 WithLoggerContext ¶
WithLoggerContext returns a new context with a set logger
func Wrap ¶
func Wrap(z *zap.SugaredLogger) log.LoggerCloser
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
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.
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.
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.
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.