protolion

package
v0.0.0-...-304b2f4 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2019 License: MIT Imports: 13 Imported by: 33

Documentation

Overview

Package protolion defines the Protocol Buffers functionality for lion.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Encoding is the name of the encoding.
	Encoding = "proto"

	// DelimitedMarshaller is a Marshaller that uses the protocol buffers write delimited scheme.
	DelimitedMarshaller = newDelimitedMarshaller(false, false)
	// DelimitedUnmarshaller is an Unmarshaller that uses the protocol buffers write delimited scheme.
	DelimitedUnmarshaller = newDelimitedUnmarshaller(false, false)
	// Base64DelimitedMarshaller is a Marshaller that uses the protocol buffers write delimited scheme,
	// but encodes the encoded protocol buffer message using base64.StdEncoding.
	Base64DelimitedMarshaller = newDelimitedMarshaller(true, false)
	// Base64DelimitedUnmarshaller is an Unmarshaller that uses the protocol buffers write delimited scheme,
	// but decoded the encoded protocol buffer message using base64.StdEncoding.
	Base64DelimitedUnmarshaller = newDelimitedUnmarshaller(true, false)
	// Base64DelimitedNewlineMarshaller is a Marshaller that uses the protocol buffers write delimited scheme,
	// but encodes the encoded protocol buffer message using base64.StdEncoding, and a newline is added.
	Base64DelimitedNewlineMarshaller = newDelimitedMarshaller(true, true)
	// Base64DelimitedNewlineUnmarshaller is an Unmarshaller that uses the protocol buffers write delimited scheme,
	// but decoded the encoded protocol buffer message using base64.StdEncoding, and a newline is read at the end.
	Base64DelimitedNewlineUnmarshaller = newDelimitedUnmarshaller(true, true)
	// DefaultJSONMarshalFunc is the default protocol buffers JSONMarshalFunc.
	DefaultJSONMarshalFunc = func(writer io.Writer, data interface{}) error {
		if message, ok := data.(proto.Message); ok {
			return globalJSONMarshaler.Marshal(writer, message)
		}
		return lion.DefaultJSONMarshalFunc(writer, data)
	}
)
View Source
var Level_name = map[int32]string{
	0: "LEVEL_DEBUG",
	1: "LEVEL_INFO",
	2: "LEVEL_WARN",
	3: "LEVEL_ERROR",
	4: "LEVEL_FATAL",
	5: "LEVEL_PANIC",
	6: "LEVEL_NONE",
}
View Source
var Level_value = map[string]int32{
	"LEVEL_DEBUG": 0,
	"LEVEL_INFO":  1,
	"LEVEL_WARN":  2,
	"LEVEL_ERROR": 3,
	"LEVEL_FATAL": 4,
	"LEVEL_PANIC": 5,
	"LEVEL_NONE":  6,
}

Functions

func Debug

func Debug(event proto.Message)

Debug calls Debug on the global Logger.

func DebugWriter

func DebugWriter() io.Writer

DebugWriter calls DebugWriter on the global Logger.

func Debugf

func Debugf(format string, args ...interface{})

Debugf calls Debugf on the global Logger.

func Debugln

func Debugln(args ...interface{})

Debugln calls Debugln on the global Logger.

func Error

func Error(event proto.Message)

Error calls Error on the global Logger.

func ErrorWriter

func ErrorWriter() io.Writer

ErrorWriter calls ErrorWriter on the global Logger.

func Errorf

func Errorf(format string, args ...interface{})

Errorf calls Errorf on the global Logger.

func Errorln

func Errorln(args ...interface{})

Errorln calls Errorln on the global Logger.

func Fatal

func Fatal(event proto.Message)

Fatal calls Fatal on the global Logger.

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf calls Fatalf on the global Logger.

func Fatalln

func Fatalln(args ...interface{})

Fatalln calls Fatalln on the global Logger.

func Flush

func Flush() error

Flush calls Flush on the global Logger.

func Info

func Info(event proto.Message)

Info calls Info on the global Logger.

func InfoWriter

func InfoWriter() io.Writer

InfoWriter calls InfoWriter on the global Logger.

func Infof

func Infof(format string, args ...interface{})

Infof calls Infof on the global Logger.

func Infoln

func Infoln(args ...interface{})

Infoln calls Infoln on the global Logger.

func LionLogger

func LionLogger() lion.Logger

LionLogger calls LionLogger on the global Logger.

func Panic

func Panic(event proto.Message)

Panic calls Panic on the global Logger.

func Panicf

func Panicf(format string, args ...interface{})

Panicf calls Panicf on the global Logger.

func Panicln

func Panicln(args ...interface{})

Panicln calls Panicln on the global Logger.

func Print

func Print(event proto.Message)

Print calls Print on the global Logger.

func Printf

func Printf(format string, args ...interface{})

Printf calls Printf on the global Logger.

func Println

func Println(args ...interface{})

Println calls Println on the global Logger.

func Warn

func Warn(event proto.Message)

Warn calls Warn on the global Logger.

func WarnWriter

func WarnWriter() io.Writer

WarnWriter calls WarnWriter on the global Logger.

func Warnf

func Warnf(format string, args ...interface{})

Warnf calls Warnf on the global Logger.

func Warnln

func Warnln(args ...interface{})

Warnln calls Warnln on the global Logger.

func Writer

func Writer() io.Writer

Writer calls Writer on the global Logger.

Types

type Entry

type Entry struct {
	// id may not be set depending on logger options
	// it is up to the user to determine if id is required
	Id        string     `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
	Level     Level      `protobuf:"varint,2,opt,name=level,enum=lion.Level" json:"level,omitempty"`
	Timestamp *Timestamp `protobuf:"bytes,3,opt,name=timestamp" json:"timestamp,omitempty"`
	// both context and fields may be set
	Context []*Entry_Message  `protobuf:"bytes,4,rep,name=context" json:"context,omitempty"`
	Fields  map[string]string `` /* 132-byte string literal not displayed */
	// one of event, message, writer_output will be set
	Event        *Entry_Message `protobuf:"bytes,6,opt,name=event" json:"event,omitempty"`
	Message      string         `protobuf:"bytes,7,opt,name=message" json:"message,omitempty"`
	WriterOutput []byte         `protobuf:"bytes,8,opt,name=writer_output,json=writerOutput,proto3" json:"writer_output,omitempty"`
}

Entry is the object serialized for logging.

func (*Entry) Descriptor

func (*Entry) Descriptor() ([]byte, []int)

func (*Entry) GetContext

func (m *Entry) GetContext() []*Entry_Message

func (*Entry) GetEvent

func (m *Entry) GetEvent() *Entry_Message

func (*Entry) GetFields

func (m *Entry) GetFields() map[string]string

func (*Entry) GetId

func (m *Entry) GetId() string

func (*Entry) GetLevel

func (m *Entry) GetLevel() Level

func (*Entry) GetMessage

func (m *Entry) GetMessage() string

func (*Entry) GetTimestamp

func (m *Entry) GetTimestamp() *Timestamp

func (*Entry) GetWriterOutput

func (m *Entry) GetWriterOutput() []byte

func (*Entry) ProtoMessage

func (*Entry) ProtoMessage()

func (*Entry) Reset

func (m *Entry) Reset()

func (*Entry) String

func (m *Entry) String() string

type Entry_Message

type Entry_Message struct {
	Encoding string `protobuf:"bytes,1,opt,name=encoding" json:"encoding,omitempty"`
	Name     string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
	Value    []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
}

Message represents a serialized protobuf message. The name is the name registered with lion.

func (*Entry_Message) Descriptor

func (*Entry_Message) Descriptor() ([]byte, []int)

func (*Entry_Message) GetEncoding

func (m *Entry_Message) GetEncoding() string

func (*Entry_Message) GetName

func (m *Entry_Message) GetName() string

func (*Entry_Message) GetValue

func (m *Entry_Message) GetValue() []byte

func (*Entry_Message) ProtoMessage

func (*Entry_Message) ProtoMessage()

func (*Entry_Message) Reset

func (m *Entry_Message) Reset()

func (*Entry_Message) String

func (m *Entry_Message) String() string

type Level

type Level int32

Level is a logging level.

const (
	Level_LEVEL_DEBUG Level = 0
	Level_LEVEL_INFO  Level = 1
	Level_LEVEL_WARN  Level = 2
	Level_LEVEL_ERROR Level = 3
	Level_LEVEL_FATAL Level = 4
	Level_LEVEL_PANIC Level = 5
	Level_LEVEL_NONE  Level = 6
)

func (Level) EnumDescriptor

func (Level) EnumDescriptor() ([]byte, []int)

func (Level) String

func (x Level) String() string

type LevelLogger

type LevelLogger interface {
	lion.BaseLevelLogger

	WithField(key string, value interface{}) LevelLogger
	WithFields(fields map[string]interface{}) LevelLogger
	WithKeyValues(keyvalues ...interface{}) LevelLogger
	WithContext(context proto.Message) LevelLogger

	Print(event proto.Message)
}

LevelLogger is a lion.LevelLogger that also has proto logging methods.

func LogDebug

func LogDebug() LevelLogger

LogDebug calls LogDebug on the global Logger.

func LogInfo

func LogInfo() LevelLogger

LogInfo calls LogInfo on the global Logger.

type Logger

type Logger interface {
	lion.BaseLogger

	AtLevel(level lion.Level) Logger
	WithField(key string, value interface{}) Logger
	WithFields(fields map[string]interface{}) Logger
	WithKeyValues(keyValues ...interface{}) Logger

	WithContext(context proto.Message) Logger
	Debug(event proto.Message)
	Info(event proto.Message)
	Warn(event proto.Message)
	Error(event proto.Message)
	Fatal(event proto.Message)
	Panic(event proto.Message)
	Print(event proto.Message)

	// NOTE: this function name may change, this is experimental
	LogDebug() LevelLogger
	// NOTE: this function name may change, this is experimental
	LogInfo() LevelLogger

	LionLogger() lion.Logger
}

Logger is a lion.Logger that also has proto logging methods.

func AtLevel

func AtLevel(level lion.Level) Logger

AtLevel calls AtLevel on the global Logger.

func GlobalLogger

func GlobalLogger() Logger

GlobalLogger returns the global Logger instance.

func NewLogger

func NewLogger(delegate lion.Logger) Logger

NewLogger returns a new Logger.

func WithContext

func WithContext(context proto.Message) Logger

WithContext calls WithContext on the global Logger.

func WithField

func WithField(key string, value interface{}) Logger

WithField calls WithField on the global Logger.

func WithFields

func WithFields(fields map[string]interface{}) Logger

WithFields calls WithFields on the global Logger.

func WithKeyValues

func WithKeyValues(keyValues ...interface{}) Logger

WithKeyValues calls WithKeyValues on the global Logger.

type Timestamp

type Timestamp struct {
	Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"`
	Nanos   int32 `protobuf:"varint,2,opt,name=nanos" json:"nanos,omitempty"`
}

func (*Timestamp) Descriptor

func (*Timestamp) Descriptor() ([]byte, []int)

func (*Timestamp) GetNanos

func (m *Timestamp) GetNanos() int32

func (*Timestamp) GetSeconds

func (m *Timestamp) GetSeconds() int64

func (*Timestamp) ProtoMessage

func (*Timestamp) ProtoMessage()

func (*Timestamp) Reset

func (m *Timestamp) Reset()

func (*Timestamp) String

func (m *Timestamp) String() string

Directories

Path Synopsis
Package protoliontesting defines testing for protolion.
Package protoliontesting defines testing for protolion.

Jump to

Keyboard shortcuts

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