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
- func Debug(obj ...interface{})
- func Debugf(msg string, obj ...interface{})
- func Debugln(obj ...interface{})
- func Destroy()
- func Error(obj ...interface{})
- func Errorf(msg string, obj ...interface{})
- func Errorln(obj ...interface{})
- func Fatal(obj ...interface{})
- func Fatalf(msg string, obj ...interface{})
- func Fatalln(obj ...interface{})
- func Info(obj ...interface{})
- func Infof(msg string, obj ...interface{})
- func Infoln(obj ...interface{})
- func Panic(obj ...interface{})
- func Panicf(msg string, obj ...interface{})
- func Panicln(obj ...interface{})
- func SetDefaultLogger(l *Logger)
- func Trace(obj ...interface{})
- func Tracef(msg string, obj ...interface{})
- func Traceln(obj ...interface{})
- func Warn(obj ...interface{})
- func Warnf(msg string, obj ...interface{})
- func Warning(obj ...interface{})
- func Warningf(msg string, obj ...interface{})
- func Warningln(obj ...interface{})
- func Warnln(obj ...interface{})
- type Core
- type Entry
- func (e *Entry) Add(r *service.Registry)
- func (b *Entry) Debug(obj ...interface{})
- func (b *Entry) Debugf(msg string, obj ...interface{})
- func (b *Entry) Debugln(obj ...interface{})
- func (b *Entry) Error(obj ...interface{})
- func (b *Entry) Errorf(msg string, obj ...interface{})
- func (b *Entry) Errorln(obj ...interface{})
- func (b *Entry) Fatal(obj ...interface{})
- func (b *Entry) Fatalf(msg string, obj ...interface{})
- func (b *Entry) Fatalln(obj ...interface{})
- func (b *Entry) Info(obj ...interface{})
- func (b *Entry) Infof(msg string, obj ...interface{})
- func (b *Entry) Infoln(obj ...interface{})
- func (e *Entry) NewService(opts ...ServiceOption) service.Services
- func (b *Entry) Panic(obj ...interface{})
- func (b *Entry) Panicf(msg string, obj ...interface{})
- func (b *Entry) Panicln(obj ...interface{})
- func (b *Entry) Trace(obj ...interface{})
- func (b *Entry) Tracef(msg string, obj ...interface{})
- func (b *Entry) Traceln(obj ...interface{})
- func (b *Entry) Warn(obj ...interface{})
- func (b *Entry) Warnf(msg string, obj ...interface{})
- func (b *Entry) Warning(obj ...interface{})
- func (b *Entry) Warningf(msg string, obj ...interface{})
- func (b *Entry) Warningln(obj ...interface{})
- func (b *Entry) Warnln(obj ...interface{})
- type Fields
- type Level
- type Log
- type Logger
- func (l *Logger) Add(r *service.Registry)
- func (b *Logger) Debug(obj ...interface{})
- func (b *Logger) Debugf(msg string, obj ...interface{})
- func (b *Logger) Debugln(obj ...interface{})
- func (b *Logger) Error(obj ...interface{})
- func (b *Logger) Errorf(msg string, obj ...interface{})
- func (b *Logger) Errorln(obj ...interface{})
- func (b *Logger) Fatal(obj ...interface{})
- func (b *Logger) Fatalf(msg string, obj ...interface{})
- func (b *Logger) Fatalln(obj ...interface{})
- func (b *Logger) Info(obj ...interface{})
- func (b *Logger) Infof(msg string, obj ...interface{})
- func (b *Logger) Infoln(obj ...interface{})
- func (l *Logger) NewService(opts ...ServiceOption) service.Services
- func (b *Logger) Panic(obj ...interface{})
- func (b *Logger) Panicf(msg string, obj ...interface{})
- func (b *Logger) Panicln(obj ...interface{})
- func (b *Logger) Trace(obj ...interface{})
- func (b *Logger) Tracef(msg string, obj ...interface{})
- func (b *Logger) Traceln(obj ...interface{})
- func (b *Logger) Warn(obj ...interface{})
- func (b *Logger) Warnf(msg string, obj ...interface{})
- func (b *Logger) Warning(obj ...interface{})
- func (b *Logger) Warningf(msg string, obj ...interface{})
- func (b *Logger) Warningln(obj ...interface{})
- func (b *Logger) Warnln(obj ...interface{})
- func (l *Logger) WithFields(f Fields) *Entry
- type ServiceOption
Constants ¶
const Namespace = "github.com/chaitin/libveinmind/logging"
Variables ¶
This section is empty.
Functions ¶
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.
Types ¶
type Core ¶
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 (*Entry) NewService ¶
func (e *Entry) NewService(opts ...ServiceOption) service.Services
type Fields ¶
type Fields map[string]interface{}
Fields that will be marshaled and used while logging.
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 NewLogrus ¶
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) NewService ¶
func (l *Logger) NewService(opts ...ServiceOption) service.Services
func (*Logger) WithFields ¶
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.