logger

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelEmergency = iota
	LevelAlert
	LevelCritical
	LevelError
	LevelWarning
	LevelNotice
	LevelInformational
	LevelDebug
)

RFC5424 log message levels.

View Source
const (
	AdapterConsole   = "console"
	AdapterFile      = "file"
	AdapterMultiFile = "multi_file"
	AdapterConn      = "conn"
)

Name for adapter

View Source
const (
	LevelInfo  = LevelInformational
	LevelTrace = LevelDebug
	LevelWarn  = LevelWarning
)

Legacy log level constants to ensure backwards compatibility.

Variables

This section is empty.

Functions

func NewConn

func NewConn() logger

NewConn create new ConnWrite returning as LoggerInterface.

func NewConsole

func NewConsole() logger

NewConsole create ConsoleWriter returning as LoggerInterface.

func Register

func Register(name string, log newLoggerFunc)

Register makes a log provide available by the provided name. If Register is called twice with the same name or if driver is nil, it panics.

Types

type Logger

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

Logger is default logger. it can contain several providers and log message into all providers.

func NewLogger

func NewLogger(channelLens ...int64) *Logger

NewLogger returns a new Logger. channelLen means the number of messages in chan(used where asynchronous is true). if the buffering chan is full, logger adapters write to file or other way.

func (*Logger) Alert

func (bl *Logger) Alert(f interface{}, v ...interface{})

Alert Log ALERT level message.

func (*Logger) Async

func (bl *Logger) Async(msgLen ...int64) *Logger

Async set the log to asynchronous and start the goroutine

func (*Logger) Close

func (bl *Logger) Close()

Close close logger, flush all chan data and destroy all adapters in Logger.

func (*Logger) Critical

func (bl *Logger) Critical(f interface{}, v ...interface{})

Critical Log CRITICAL level message.

func (*Logger) Debug

func (bl *Logger) Debug(f interface{}, v ...interface{})

Debug Log DEBUG level message.

func (*Logger) DelLogger

func (bl *Logger) DelLogger(adapterName string) error

DelLogger remove a logger adapter in Logger.

func (*Logger) Emergency

func (bl *Logger) Emergency(f interface{}, v ...interface{})

Emergency Log EMERGENCY level message.

func (*Logger) EnableFuncCallDepth

func (bl *Logger) EnableFuncCallDepth(b bool)

EnableFuncCallDepth enable log funcCallDepth

func (*Logger) Error

func (bl *Logger) Error(f interface{}, v ...interface{})

Error Log ERROR level message.

func (*Logger) Flush

func (bl *Logger) Flush()

Flush flush all chan data.

func (*Logger) GetLevel

func (bl *Logger) GetLevel() int

GetLevel Get Current log message level.

func (*Logger) GetLogFuncCallDepth

func (bl *Logger) GetLogFuncCallDepth() int

GetLogFuncCallDepth return log funcCallDepth for wrapper

func (*Logger) Info

func (bl *Logger) Info(f interface{}, v ...interface{})

Info Log INFO level message. compatibility alias for Informational()

func (*Logger) Informational

func (bl *Logger) Informational(f interface{}, v ...interface{})

Informational Log INFORMATIONAL level message.

func (*Logger) Notice

func (bl *Logger) Notice(f interface{}, v ...interface{})

Notice Log NOTICE level message.

func (*Logger) Reset

func (bl *Logger) Reset()

Reset close all outputs, and set bl.outputs to nil

func (*Logger) SetLevel

func (bl *Logger) SetLevel(l int)

SetLevel Set log message level. If message level (such as LevelDebug) is higher than logger level (such as LevelWarning), log providers will not even be sent the message.

func (*Logger) SetLogFuncCallDepth

func (bl *Logger) SetLogFuncCallDepth(d int)

SetLogFuncCallDepth set log funcCallDepth

func (*Logger) SetLogger

func (bl *Logger) SetLogger(adapterName string, configs ...string) error

SetLogger provides a given logger adapter into Logger with config string. config need to be correct JSON as string: {"interval":360}.

func (*Logger) SetPrefix

func (bl *Logger) SetPrefix(s string)

set prefix

func (*Logger) Trace

func (bl *Logger) Trace(f interface{}, v ...interface{})

Trace Log TRACE level message. compatibility alias for Debug()

func (*Logger) Warn

func (bl *Logger) Warn(f interface{}, v ...interface{})

Warn Log WARN level message. compatibility alias for Warning()

func (*Logger) Warning

func (bl *Logger) Warning(f interface{}, v ...interface{})

Warning Log WARNING level message.

func (*Logger) Write

func (bl *Logger) Write(p []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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