logger

package
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LevelNames = map[Level]string{
	LevelDebug:     "Debug",
	LevelInfo:      "Info",
	LevelNotice:    "Notice",
	LevelWarning:   "Warning",
	LevelError:     "Error",
	LevelCritical:  "Critical",
	LevelAlert:     "Alert",
	LevelEmergency: "Emergency",
}

LevelNames maps log levels to names

Functions

func DefaultLogFormatter

func DefaultLogFormatter() libLogger.Formatter

func NewConsoleTarget

func NewConsoleTarget() *libLogger.ConsoleTarget

func NewFileTarget

func NewFileTarget() *libLogger.FileTarget

func RawLogFormatter

func RawLogFormatter() libLogger.Formatter

func Register

func Register(name string, logHandler logHandler) error

func SysLogFormatter

func SysLogFormatter() libLogger.Formatter

func Use

func Use(name string) (logHandler, error)

Types

type Handler

type Handler interface {
	Initiate(ctx context.Context) error
	NewLogger(name string) *libLogger.Logger
	GetLogger(name string) (*libLogger.Logger, error)
	GetLoggerTarget(name string) (libLogger.Target, error)
	RegisterLoggerTarget(name string, targetType string, targetConfig string) error
	SetLoggerTarget(name string, targetName string) error
	SetLoggerMaxLevel(name string, level libLogger.Level) error
	SetLoggerCallStackDepth(name string, d int) error
	SetLoggerCallStackFilter(name string, f string) error
	SetLoggerFormatter(name string, f libLogger.Formatter) error
	SetLoggerBufferSize(name string, b int) error
	OpenLogger(name string) error
	CloseLogger(name string) error
}

func NewTickHandler

func NewTickHandler() Handler

type Instance

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

func NewInstance

func NewInstance() *Instance

func (*Instance) CloseLogger

func (this *Instance) CloseLogger(name string) error

func (*Instance) GetLogger

func (this *Instance) GetLogger(name string) (*libLogger.Logger, error)

func (*Instance) GetLoggerTarget

func (this *Instance) GetLoggerTarget(name string) (libLogger.Target, error)

func (*Instance) HandlerName

func (this *Instance) HandlerName() string

func (*Instance) Initiate

func (this *Instance) Initiate(ctx context.Context) (context.Context, error)

func (*Instance) LoadModuleFileConfig

func (this *Instance) LoadModuleFileConfig(configFile string, configProviders map[string]interface{}, configTag ...string) (err error)

func (*Instance) LoadModuleJsonConfig

func (this *Instance) LoadModuleJsonConfig(configData []byte, configProviders map[string]interface{}, configTag ...string) (err error)

func (*Instance) NewLogger

func (this *Instance) NewLogger(name string) *libLogger.Logger

func (*Instance) OnRequestShutdown

func (this *Instance) OnRequestShutdown(c *routing.Context) error

func (*Instance) OnRequestStartup

func (this *Instance) OnRequestStartup(c *routing.Context) error

func (*Instance) OnShutdown

func (this *Instance) OnShutdown(ctx context.Context) (context.Context, error)

func (*Instance) OnStartup

func (this *Instance) OnStartup(ctx context.Context) (context.Context, error)

func (*Instance) OpenLogger

func (this *Instance) OpenLogger(name string) error

func (*Instance) RegisterLoggerTarget

func (this *Instance) RegisterLoggerTarget(name string, targetType string, targetConfig string) error

func (*Instance) SetLoggerBufferSize

func (this *Instance) SetLoggerBufferSize(name string, b int) error

func (*Instance) SetLoggerCallStackDepth

func (this *Instance) SetLoggerCallStackDepth(name string, d int) error

func (*Instance) SetLoggerCallStackFilter

func (this *Instance) SetLoggerCallStackFilter(name string, f string) error

func (*Instance) SetLoggerFormatter

func (this *Instance) SetLoggerFormatter(name string, f libLogger.Formatter) error

func (*Instance) SetLoggerMaxLevel

func (this *Instance) SetLoggerMaxLevel(name string, level Level) error

func (*Instance) SetLoggerTarget

func (this *Instance) SetLoggerTarget(name string, targetName string) error

func (*Instance) Use

func (this *Instance) Use(ctx context.Context, handlerName string) error

type Level

type Level int

Level describes the level of a log message.

const (
	LevelEmergency Level = iota
	LevelAlert
	LevelCritical
	LevelError
	LevelWarning
	LevelNotice
	LevelInfo
	LevelDebug
)

RFC5424 log message levels.

func (Level) String

func (l Level) String() string

String returns the string representation of the log level

type Logger

type Logger struct {
	*libLogger.Logger
}

type TickHandler

type TickHandler struct {
	Loggers map[string]*libLogger.Logger
	Targets map[string]libLogger.Target
	// contains filtered or unexported fields
}

func (*TickHandler) CloseLogger

func (this *TickHandler) CloseLogger(name string) error

CloseLogger close all targets in Logger.

func (*TickHandler) GetLogger

func (this *TickHandler) GetLogger(name string) (*libLogger.Logger, error)

GetLogger.

func (*TickHandler) GetLoggerTarget

func (this *TickHandler) GetLoggerTarget(name string) (libLogger.Target, error)

func (*TickHandler) Initiate

func (this *TickHandler) Initiate(ctx context.Context) error

func (*TickHandler) NewLogger

func (this *TickHandler) NewLogger(name string) *libLogger.Logger

SetLogger provides a given logger adapter into Logger with config string. config need to be correct JSON as string: File config sample: {

"MaxLevel": 2,
"Rotate": true,
"BackupCount": 100000,
"MaxBytes": 1024,

}

func (*TickHandler) OpenLogger

func (this *TickHandler) OpenLogger(name string) error

CloseLogger close all targets in Logger.

func (*TickHandler) RegisterLoggerTarget

func (this *TickHandler) RegisterLoggerTarget(name string, targetType string, targetConfig string) error

func (*TickHandler) SetLoggerBufferSize

func (this *TickHandler) SetLoggerBufferSize(name string, b int) error

SetLoggerCallStackFilter.

func (*TickHandler) SetLoggerCallStackDepth

func (this *TickHandler) SetLoggerCallStackDepth(name string, d int) error

SetLoggerCallStackDepth.

func (*TickHandler) SetLoggerCallStackFilter

func (this *TickHandler) SetLoggerCallStackFilter(name string, f string) error

SetLoggerCallStackFilter.

func (*TickHandler) SetLoggerFormatter

func (this *TickHandler) SetLoggerFormatter(name string, f libLogger.Formatter) error

SetLoggerSetFormatter.

func (*TickHandler) SetLoggerMaxLevel

func (this *TickHandler) SetLoggerMaxLevel(name string, level libLogger.Level) error

SetLoggerMaxLevel.

func (*TickHandler) SetLoggerTarget

func (this *TickHandler) SetLoggerTarget(name string, targetName string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL