log

package
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 9 Imported by: 47

Documentation

Overview

Package plugin/log provides a common log system that is based on the plugin/service.

Unlike the scenario of those in logrus and zap, the log in each plugins should be transferred back to the host. And the bottleneck should be the case of IPC that the plugin waits for the host's loggerBase result. So there're several related control parameter while creating loggers.

Index

Constants

View Source
const Namespace = "github.com/chaitin/libveinmind/logging"

Variables

This section is empty.

Functions

func Debug

func Debug(obj ...interface{})

func Debugf

func Debugf(msg string, obj ...interface{})

func Debugln

func Debugln(obj ...interface{})

func Destroy

func Destroy()

Destroy after synchronizing the default logger initialized.

func Error

func Error(obj ...interface{})

func Errorf

func Errorf(msg string, obj ...interface{})

func Errorln

func Errorln(obj ...interface{})

func Fatal

func Fatal(obj ...interface{})

func Fatalf

func Fatalf(msg string, obj ...interface{})

func Fatalln

func Fatalln(obj ...interface{})

func Info

func Info(obj ...interface{})

func Infof

func Infof(msg string, obj ...interface{})

func Infoln

func Infoln(obj ...interface{})

func Panic

func Panic(obj ...interface{})

func Panicf

func Panicf(msg string, obj ...interface{})

func Panicln

func Panicln(obj ...interface{})

func SetDefaultLogger

func SetDefaultLogger(l *Logger)

SetDefaultLogger updates the default logger if not hosted.

The logger provided will be ignored if it is being hosted, and it is recommended to invoke the program right at the start since it is not synchronized.

func Trace

func Trace(obj ...interface{})

func Tracef

func Tracef(msg string, obj ...interface{})

func Traceln

func Traceln(obj ...interface{})

func Warn

func Warn(obj ...interface{})

func Warnf

func Warnf(msg string, obj ...interface{})

func Warning

func Warning(obj ...interface{})

func Warningf

func Warningf(msg string, obj ...interface{})

func Warningln

func Warningln(obj ...interface{})

func Warnln

func Warnln(obj ...interface{})

Types

type Core

type Core interface {
	Enabled(level Level) bool
	Do(Log)
}

Core is the core object that is sugared by the logger but performs the actual loggerBase behaviour.

type Entry

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

Entry is the decorated logging entry.

func WithFields

func WithFields(fields Fields) *Entry

func (*Entry) Add

func (e *Entry) Add(r *service.Registry)

func (*Entry) Debug

func (b *Entry) Debug(obj ...interface{})

func (*Entry) Debugf

func (b *Entry) Debugf(msg string, obj ...interface{})

func (*Entry) Debugln

func (b *Entry) Debugln(obj ...interface{})

func (*Entry) Error

func (b *Entry) Error(obj ...interface{})

func (*Entry) Errorf

func (b *Entry) Errorf(msg string, obj ...interface{})

func (*Entry) Errorln

func (b *Entry) Errorln(obj ...interface{})

func (*Entry) Fatal

func (b *Entry) Fatal(obj ...interface{})

func (*Entry) Fatalf

func (b *Entry) Fatalf(msg string, obj ...interface{})

func (*Entry) Fatalln

func (b *Entry) Fatalln(obj ...interface{})

func (*Entry) Info

func (b *Entry) Info(obj ...interface{})

func (*Entry) Infof

func (b *Entry) Infof(msg string, obj ...interface{})

func (*Entry) Infoln

func (b *Entry) Infoln(obj ...interface{})

func (*Entry) NewService

func (e *Entry) NewService(opts ...ServiceOption) service.Services

func (*Entry) Panic

func (b *Entry) Panic(obj ...interface{})

func (*Entry) Panicf

func (b *Entry) Panicf(msg string, obj ...interface{})

func (*Entry) Panicln

func (b *Entry) Panicln(obj ...interface{})

func (*Entry) Trace

func (b *Entry) Trace(obj ...interface{})

func (*Entry) Tracef

func (b *Entry) Tracef(msg string, obj ...interface{})

func (*Entry) Traceln

func (b *Entry) Traceln(obj ...interface{})

func (*Entry) Warn

func (b *Entry) Warn(obj ...interface{})

func (*Entry) Warnf

func (b *Entry) Warnf(msg string, obj ...interface{})

func (*Entry) Warning

func (b *Entry) Warning(obj ...interface{})

func (*Entry) Warningf

func (b *Entry) Warningf(msg string, obj ...interface{})

func (*Entry) Warningln

func (b *Entry) Warningln(obj ...interface{})

func (*Entry) Warnln

func (b *Entry) Warnln(obj ...interface{})

type Fields

type Fields map[string]interface{}

Fields that will be marshaled and used while logging.

type Level

type Level uint32
const (
	PanicLevel Level = iota
	FatalLevel
	ErrorLevel
	WarnLevel
	InfoLevel
	DebugLevel
	TraceLevel
)

type Log

type Log struct {
	Time   time.Time `json:time`
	Level  Level     `json:level`
	Fields Fields    `json:fields,omitempty`
	Msg    string    `json:msg`
}

Log is a entry created by the logger and is serializable between host and plugin.

type Logger

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

Logger is the configured and sugared logger.

func DefaultLogger

func DefaultLogger() *Logger

DefaultLogger returns the default global logger for logging.

When the program is hosted, it returns the logger that can communicate with the host. Otherwise it returns the logger that is equivalent to logrus.StandardLogger().

func New

func New(core Core) *Logger

func NewLogrus

func NewLogrus(l *logrus.Logger) *Logger

NewLogrus specifies a logrus logger as the underlying Core implementation. The plugin log will goes into a logrus logger instead of the default logger.

func (*Logger) Add

func (l *Logger) Add(r *service.Registry)

func (*Logger) Debug

func (b *Logger) Debug(obj ...interface{})

func (*Logger) Debugf

func (b *Logger) Debugf(msg string, obj ...interface{})

func (*Logger) Debugln

func (b *Logger) Debugln(obj ...interface{})

func (*Logger) Error

func (b *Logger) Error(obj ...interface{})

func (*Logger) Errorf

func (b *Logger) Errorf(msg string, obj ...interface{})

func (*Logger) Errorln

func (b *Logger) Errorln(obj ...interface{})

func (*Logger) Fatal

func (b *Logger) Fatal(obj ...interface{})

func (*Logger) Fatalf

func (b *Logger) Fatalf(msg string, obj ...interface{})

func (*Logger) Fatalln

func (b *Logger) Fatalln(obj ...interface{})

func (*Logger) Info

func (b *Logger) Info(obj ...interface{})

func (*Logger) Infof

func (b *Logger) Infof(msg string, obj ...interface{})

func (*Logger) Infoln

func (b *Logger) Infoln(obj ...interface{})

func (*Logger) NewService

func (l *Logger) NewService(opts ...ServiceOption) service.Services

func (*Logger) Panic

func (b *Logger) Panic(obj ...interface{})

func (*Logger) Panicf

func (b *Logger) Panicf(msg string, obj ...interface{})

func (*Logger) Panicln

func (b *Logger) Panicln(obj ...interface{})

func (*Logger) Trace

func (b *Logger) Trace(obj ...interface{})

func (*Logger) Tracef

func (b *Logger) Tracef(msg string, obj ...interface{})

func (*Logger) Traceln

func (b *Logger) Traceln(obj ...interface{})

func (*Logger) Warn

func (b *Logger) Warn(obj ...interface{})

func (*Logger) Warnf

func (b *Logger) Warnf(msg string, obj ...interface{})

func (*Logger) Warning

func (b *Logger) Warning(obj ...interface{})

func (*Logger) Warningf

func (b *Logger) Warningf(msg string, obj ...interface{})

func (*Logger) Warningln

func (b *Logger) Warningln(obj ...interface{})

func (*Logger) Warnln

func (b *Logger) Warnln(obj ...interface{})

func (*Logger) WithFields

func (l *Logger) WithFields(f Fields) *Entry

type ServiceOption

type ServiceOption func(*serviceOption)

ServiceOption are the options for creating logger services and provide it to plugins to execute.

func WithBufferDelay

func WithBufferDelay(d time.Duration) ServiceOption

WithBufferDelay sets timeout of log buffering before they could be sent back to the host.

func WithMaxLevel

func WithMaxLevel(level Level) ServiceOption

WithMaxLevel sets the maximum level of log that will be transferred back to the host from plugin.

func WithNoBuffer

func WithNoBuffer() ServiceOption

WithNoBuffer tells the plugin to send back logs to the host without internal buffering.

Jump to

Keyboard shortcuts

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