protoactor-go: github.com/AsynkronIT/protoactor-go/log Index | Files

package log

import "github.com/AsynkronIT/protoactor-go/log"

Package log provides simple log interfaces

Index

Package Files

encoder.go event.go field.go log.go options.go stream.go string_encoder.go

Constants

const (
    MinLevel = Level(iota)
    DebugLevel
    InfoLevel
    ErrorLevel
    OffLevel
)

func SetOptions Uses

func SetOptions(opts ...optionFn)

SetOptions is used to configure the log system

func Unsubscribe Uses

func Unsubscribe(sub *Subscription)

func WithEventSubscriber Uses

func WithEventSubscriber(fn func(evt Event)) optionFn

WithEventSubscriber option replaces the default Event subscriber with fn.

Specifying nil will disable logging of events.

type Encoder Uses

type Encoder interface {
    EncodeBool(key string, val bool)
    EncodeFloat64(key string, val float64)
    EncodeInt(key string, val int)
    EncodeInt64(key string, val int64)
    EncodeDuration(key string, val time.Duration)
    EncodeUint(key string, val uint)
    EncodeUint64(key string, val uint64)
    EncodeString(key string, val string)
    EncodeObject(key string, val interface{})
    EncodeType(key string, val reflect.Type)
}

type Event Uses

type Event struct {
    Time    time.Time
    Level   Level
    Prefix  string
    Message string
    Context []Field
    Fields  []Field
}

type Field Uses

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

func Bool Uses

func Bool(key string, val bool) Field

Bool constructs a Field with the given key and value.

func Duration Uses

func Duration(key string, val time.Duration) Field

Duration constructs a Field with the given key and value.

func Error Uses

func Error(err error) Field

Error constructs a Field that lazily stores err.Error() under the key "error". If passed a nil error, the field is skipped.

func Float64 Uses

func Float64(key string, val float64) Field

Float64 constructs a Field with the given key and value.

func Int Uses

func Int(key string, val int) Field

Int constructs a Field with the given key and value. Marshaling ints is lazy.

func Int64 Uses

func Int64(key string, val int64) Field

Int64 constructs a Field with the given key and value.

func Message Uses

func Message(val interface{}) Field

Message constructs a field to store the message under the key message

func Object Uses

func Object(key string, val interface{}) Field

Object constructs a field with the given key and an arbitrary object.

func Stack Uses

func Stack() Field

Stack constructs a Field that stores a stacktrace under the key "stacktrace".

This is eager and therefore an expensive operation.

func String Uses

func String(key string, val string) Field

String constructs a Field with the given key and value.

func Stringer Uses

func Stringer(key string, val fmt.Stringer) Field

Stringer constructs a Field with the given key and the output of the value's String method. The String is not evaluated until encoding.

func Time Uses

func Time(key string, val time.Time) Field

Time constructs a Field with the given key and value. It represents a time.Time as a floating-point number of seconds since the Unix epoch.

func TypeOf Uses

func TypeOf(key string, val interface{}) Field

TypeOf constructs a field with the given key and an arbitrary object that will log the type information lazily.

func Uint Uses

func Uint(key string, val uint) Field

Uint constructs a Field with the given key and value.

func Uint64 Uses

func Uint64(key string, val uint64) Field

Uint64 constructs a Field with the given key and value.

func (Field) Encode Uses

func (f Field) Encode(enc Encoder)

Encode encodes a field to a type safe val via the encoder.

type Level Uses

type Level int32

type Logger Uses

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

func New Uses

func New(level Level, prefix string, context ...Field) *Logger

func (*Logger) Debug Uses

func (l *Logger) Debug(msg string, fields ...Field)

func (*Logger) Error Uses

func (l *Logger) Error(msg string, fields ...Field)

func (*Logger) Info Uses

func (l *Logger) Info(msg string, fields ...Field)

func (*Logger) Level Uses

func (l *Logger) Level() Level

func (*Logger) SetLevel Uses

func (l *Logger) SetLevel(level Level)

func (*Logger) With Uses

func (l *Logger) With(fields ...Field) *Logger

type Subscription Uses

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

Subscription is returned from the Subscribe function.

This value and can be passed to Unsubscribe when the observer is no longer interested in receiving messages

func Subscribe Uses

func Subscribe(fn func(evt Event)) *Subscription

func (*Subscription) WithMinLevel Uses

func (s *Subscription) WithMinLevel(level Level) *Subscription

WithMinLevel filter messages below the provided level

For example, setting ErrorLevel will only pass error messages. Setting MinLevel will allow all messages, and is the default.

Package log imports 10 packages (graph) and is imported by 4 packages. Updated 2017-11-01. Refresh now. Tools for package owners.