logs

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2022 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package logs provide a general log interface Usage:

import "github.com/W3-Engineers-Ltd/Radiant/core/logs"

log := NewLogger(10000)
log.SetLogger("console", "")

> the first params stand for how many channel

Use it like this:

	log.Trace("trace")
	log.Info("info")
	log.Warn("warning")
	log.Debug("debug")
	log.Critical("critical")

 more docs http://beego.me/docs/module/logs.md

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 beego 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

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

func ColorByMethod(method string) string

ColorByMethod return color by http code

func ColorByStatus

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 BeeLogger

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

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

type AccessLogRecord logs.AccessLogRecord

AccessLogRecord struct for holding access log data.

type BeeLogger added in v1.0.0

type BeeLogger logs.BeeLogger

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

func Async

func Async(msgLen ...int64) *BeeLogger

Async set the beelogger with Async mode and hold msglen messages

func GetBeeLogger added in v1.0.0

func GetBeeLogger() *BeeLogger

GetBeeLogger returns the default BeeLogger

func NewLogger

func NewLogger(channelLens ...int64) *BeeLogger

NewLogger returns a new BeeLogger. 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 (*BeeLogger) Alert added in v1.0.0

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

Alert Log ALERT level message.

func (*BeeLogger) Async added in v1.0.0

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

Async set the log to asynchronous and start the goroutine

func (*BeeLogger) Close added in v1.0.0

func (bl *BeeLogger) Close()

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

func (*BeeLogger) Critical added in v1.0.0

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

Critical Log CRITICAL level message.

func (*BeeLogger) Debug added in v1.0.0

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

Debug Log DEBUG level message.

func (*BeeLogger) DelLogger added in v1.0.0

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

DelLogger remove a logger adapter in BeeLogger.

func (*BeeLogger) Emergency added in v1.0.0

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

Emergency Log EMERGENCY level message.

func (*BeeLogger) EnableFuncCallDepth added in v1.0.0

func (bl *BeeLogger) EnableFuncCallDepth(b bool)

EnableFuncCallDepth enable log funcCallDepth

func (*BeeLogger) Error added in v1.0.0

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

Error Log ERROR level message.

func (*BeeLogger) Flush added in v1.0.0

func (bl *BeeLogger) Flush()

Flush flush all chan data.

func (*BeeLogger) GetLevel added in v1.0.0

func (bl *BeeLogger) GetLevel() int

GetLevel Get Current log message level.

func (*BeeLogger) GetLogFuncCallDepth added in v1.0.0

func (bl *BeeLogger) GetLogFuncCallDepth() int

GetLogFuncCallDepth return log funcCallDepth for wrapper

func (*BeeLogger) Info added in v1.0.0

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

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

func (*BeeLogger) Informational added in v1.0.0

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

Informational Log INFORMATIONAL level message.

func (*BeeLogger) Notice added in v1.0.0

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

Notice Log NOTICE level message.

func (*BeeLogger) Reset added in v1.0.0

func (bl *BeeLogger) Reset()

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

func (*BeeLogger) SetLevel added in v1.0.0

func (bl *BeeLogger) 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 (*BeeLogger) SetLogFuncCallDepth added in v1.0.0

func (bl *BeeLogger) SetLogFuncCallDepth(d int)

SetLogFuncCallDepth set log funcCallDepth

func (*BeeLogger) SetLogger added in v1.0.0

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

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

func (*BeeLogger) SetPrefix added in v1.0.0

func (bl *BeeLogger) SetPrefix(s string)

set prefix

func (*BeeLogger) Trace added in v1.0.0

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

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

func (*BeeLogger) Warn added in v1.0.0

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

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

func (*BeeLogger) Warning added in v1.0.0

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

Warning Log WARNING level message.

func (*BeeLogger) Write added in v1.0.0

func (bl *BeeLogger) 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