logs

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: MIT Imports: 3 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 = "multifile"
	AdapterMail      = "smtp"
	AdapterConn      = "conn"
	AdapterEs        = "es"
	AdapterJianLiao  = "jianliao"
	AdapterSlack     = "slack"
	AdapterAliLS     = "alils"
)

Name for adapter with Bhojpur official support

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

Legacy log level constants to ensure backwards compatibility.

Variables

This section is empty.

Functions

func AccessLog added in v0.0.4

func AccessLog(r *AccessLogRecord, format string)

AccessLog - Format and print access log.

func Alert

func Alert(f interface{}, v ...interface{})

Alert logs a message at alert level.

func ColorByMethod added in v0.0.4

func ColorByMethod(method string) string

ColorByMethod return color by http code

func ColorByStatus added in v0.0.4

func ColorByStatus(code int) string

ColorByStatus return color by http code 2xx return Green 3xx return White 4xx return Yellow 5xx return Red

func Critical

func Critical(f interface{}, v ...interface{})

Critical logs a message at critical level.

func Debug

func Debug(f interface{}, v ...interface{})

Debug logs a message at debug level.

func Emergency

func Emergency(f interface{}, v ...interface{})

Emergency logs a message at emergency level.

func EnableFuncCallDepth

func EnableFuncCallDepth(b bool)

EnableFuncCallDepth enable log funcCallDepth

func Error

func Error(f interface{}, v ...interface{})

Error logs a message at error level.

func GetLogger

func GetLogger(prefixes ...string) *log.Logger

GetLogger returns the default BhojpurLogger

func Info

func Info(f interface{}, v ...interface{})

Info compatibility alias for Warning()

func Informational

func Informational(f interface{}, v ...interface{})

Informational logs a message at info level.

func Notice

func Notice(f interface{}, v ...interface{})

Notice logs a message at notice level.

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.

func Reset

func Reset()

Reset will remove all the adapter

func ResetColor added in v0.0.4

func ResetColor() string

ResetColor return reset color

func SetLevel

func SetLevel(l int)

SetLevel sets the global log level used by the simple logger.

func SetLogFuncCall

func SetLogFuncCall(b bool)

SetLogFuncCall set the CallDepth, default is 4

func SetLogFuncCallDepth

func SetLogFuncCallDepth(d int)

SetLogFuncCallDepth set log funcCallDepth

func SetLogger

func SetLogger(adapter string, config ...string) error

SetLogger sets a new logger.

func SetPrefix

func SetPrefix(s string)

SetPrefix sets the prefix

func Trace

func Trace(f interface{}, v ...interface{})

Trace logs a message at trace level. compatibility alias for Warning()

func Warn

func Warn(f interface{}, v ...interface{})

Warn compatibility alias for Warning()

func Warning

func Warning(f interface{}, v ...interface{})

Warning logs a message at warning level.

Types

type AccessLogRecord added in v0.0.4

type AccessLogRecord logs.AccessLogRecord

AccessLogRecord struct for holding access log data.

type BhojpurLogger added in v0.0.4

type BhojpurLogger logs.BhojpurLogger

BhojpurLogger is default logger in Bhojpur application. it can contain several providers and log message into all providers.

func Async

func Async(msgLen ...int64) *BhojpurLogger

Async set the BhojpurLogger with Async mode and hold msglen messages

func GetBhojpurLogger added in v0.0.4

func GetBhojpurLogger() *BhojpurLogger

GetBhojpurLogger returns the default BhojpurLogger

func NewLogger

func NewLogger(channelLens ...int64) *BhojpurLogger

NewLogger returns a new BhojpurLogger. 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 (*BhojpurLogger) Alert added in v0.0.4

func (bl *BhojpurLogger) Alert(format string, v ...interface{})

Alert Log ALERT level message.

func (*BhojpurLogger) Async added in v0.0.4

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

Async set the log to asynchronous and start the goroutine

func (*BhojpurLogger) Close added in v0.0.4

func (bl *BhojpurLogger) Close()

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

func (*BhojpurLogger) Critical added in v0.0.4

func (bl *BhojpurLogger) Critical(format string, v ...interface{})

Critical Log CRITICAL level message.

func (*BhojpurLogger) Debug added in v0.0.4

func (bl *BhojpurLogger) Debug(format string, v ...interface{})

Debug Log DEBUG level message.

func (*BhojpurLogger) DelLogger added in v0.0.4

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

DelLogger remove a logger adapter in BhojpurLogger.

func (*BhojpurLogger) Emergency added in v0.0.4

func (bl *BhojpurLogger) Emergency(format string, v ...interface{})

Emergency Log EMERGENCY level message.

func (*BhojpurLogger) EnableFuncCallDepth added in v0.0.4

func (bl *BhojpurLogger) EnableFuncCallDepth(b bool)

EnableFuncCallDepth enable log funcCallDepth

func (*BhojpurLogger) Error added in v0.0.4

func (bl *BhojpurLogger) Error(format string, v ...interface{})

Error Log ERROR level message.

func (*BhojpurLogger) Flush added in v0.0.4

func (bl *BhojpurLogger) Flush()

Flush flush all chan data.

func (*BhojpurLogger) GetLevel added in v0.0.4

func (bl *BhojpurLogger) GetLevel() int

GetLevel Get Current log message level.

func (*BhojpurLogger) GetLogFuncCallDepth added in v0.0.4

func (bl *BhojpurLogger) GetLogFuncCallDepth() int

GetLogFuncCallDepth return log funcCallDepth for wrapper

func (*BhojpurLogger) Info added in v0.0.4

func (bl *BhojpurLogger) Info(format string, v ...interface{})

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

func (*BhojpurLogger) Informational added in v0.0.4

func (bl *BhojpurLogger) Informational(format string, v ...interface{})

Informational Log INFORMATIONAL level message.

func (*BhojpurLogger) Notice added in v0.0.4

func (bl *BhojpurLogger) Notice(format string, v ...interface{})

Notice Log NOTICE level message.

func (*BhojpurLogger) Reset added in v0.0.4

func (bl *BhojpurLogger) Reset()

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

func (*BhojpurLogger) SetLevel added in v0.0.4

func (bl *BhojpurLogger) 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 (*BhojpurLogger) SetLogFuncCallDepth added in v0.0.4

func (bl *BhojpurLogger) SetLogFuncCallDepth(d int)

SetLogFuncCallDepth set log funcCallDepth

func (*BhojpurLogger) SetLogger added in v0.0.4

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

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

func (*BhojpurLogger) SetPrefix added in v0.0.4

func (bl *BhojpurLogger) SetPrefix(s string)

set prefix

func (*BhojpurLogger) Trace added in v0.0.4

func (bl *BhojpurLogger) Trace(format string, v ...interface{})

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

func (*BhojpurLogger) Warn added in v0.0.4

func (bl *BhojpurLogger) Warn(format string, v ...interface{})

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

func (*BhojpurLogger) Warning added in v0.0.4

func (bl *BhojpurLogger) Warning(format string, v ...interface{})

Warning Log WARNING level message.

func (*BhojpurLogger) Write added in v0.0.4

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

type Logger

type Logger interface {
	Init(config string) error
	WriteMsg(when time.Time, msg string, level int) error
	Destroy()
	Flush()
}

Logger defines the behavior of a log provider.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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