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://radiant.me/docs/module/logs.md
Index ¶
- Constants
- func AccessLog(r *AccessLogRecord, format string)
- func Alert(f interface{}, v ...interface{})
- func ColorByMethod(method string) string
- func ColorByStatus(code int) string
- func Critical(f interface{}, v ...interface{})
- func Debug(f interface{}, v ...interface{})
- func Emergency(f interface{}, v ...interface{})
- func EnableFuncCallDepth(b bool)
- func Error(f interface{}, v ...interface{})
- func GetLogger(prefixes ...string) *log.Logger
- func Info(f interface{}, v ...interface{})
- func Informational(f interface{}, v ...interface{})
- func Notice(f interface{}, v ...interface{})
- func Register(name string, log newLoggerFunc)
- func Reset()
- func ResetColor() string
- func SetLevel(l int)
- func SetLogFuncCall(b bool)
- func SetLogFuncCallDepth(d int)
- func SetLogger(adapter string, config ...string) error
- func SetPrefix(s string)
- func Trace(f interface{}, v ...interface{})
- func Warn(f interface{}, v ...interface{})
- func Warning(f interface{}, v ...interface{})
- type AccessLogRecord
- type Logger
- type RadicalLogger
- func (bl *RadicalLogger) Alert(format string, v ...interface{})
- func (bl *RadicalLogger) Async(msgLen ...int64) *RadicalLogger
- func (bl *RadicalLogger) Close()
- func (bl *RadicalLogger) Critical(format string, v ...interface{})
- func (bl *RadicalLogger) Debug(format string, v ...interface{})
- func (bl *RadicalLogger) DelLogger(adapterName string) error
- func (bl *RadicalLogger) Emergency(format string, v ...interface{})
- func (bl *RadicalLogger) EnableFuncCallDepth(b bool)
- func (bl *RadicalLogger) Error(format string, v ...interface{})
- func (bl *RadicalLogger) Flush()
- func (bl *RadicalLogger) GetLevel() int
- func (bl *RadicalLogger) GetLogFuncCallDepth() int
- func (bl *RadicalLogger) Info(format string, v ...interface{})
- func (bl *RadicalLogger) Informational(format string, v ...interface{})
- func (bl *RadicalLogger) Notice(format string, v ...interface{})
- func (bl *RadicalLogger) Reset()
- func (bl *RadicalLogger) SetLevel(l int)
- func (bl *RadicalLogger) SetLogFuncCallDepth(d int)
- func (bl *RadicalLogger) SetLogger(adapterName string, configs ...string) error
- func (bl *RadicalLogger) SetPrefix(s string)
- func (bl *RadicalLogger) Trace(format string, v ...interface{})
- func (bl *RadicalLogger) Warn(format string, v ...interface{})
- func (bl *RadicalLogger) Warning(format string, v ...interface{})
- func (bl *RadicalLogger) Write(p []byte) (n int, err error)
Constants ¶
const ( LevelEmergency = iota LevelAlert LevelCritical LevelError LevelWarning LevelNotice LevelInformational LevelDebug )
RFC5424 log message levels.
const ( AdapterConsole = "console" AdapterFile = "file" AdapterMultiFile = "multifile" AdapterMail = "smtp" AdapterConn = "conn" AdapterEs = "es" AdapterJianLiao = "jianliao" AdapterSlack = "slack" AdapterAliLS = "alils" )
Name for adapter with radiant official support
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 ColorByMethod ¶
ColorByMethod return color by http code
func ColorByStatus ¶
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 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 Informational ¶
func Informational(f interface{}, v ...interface{})
Informational logs a message at info 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 SetLogFuncCallDepth ¶
func SetLogFuncCallDepth(d int)
SetLogFuncCallDepth set log funcCallDepth
Types ¶
type AccessLogRecord ¶
type AccessLogRecord logs.AccessLogRecord
AccessLogRecord struct for holding access log data.
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.
type RadicalLogger ¶
type RadicalLogger logs.RadicalLogger
RadicalLogger is default logger in radiant application. it can contain several providers and log message into all providers.
func Async ¶
func Async(msgLen ...int64) *RadicalLogger
Async set the radicallogger with Async mode and hold msglen messages
func GetRadicalLogger ¶
func GetRadicalLogger() *RadicalLogger
GetRadicalLogger returns the default RadicalLogger
func NewLogger ¶
func NewLogger(channelLens ...int64) *RadicalLogger
NewLogger returns a new RadicalLogger. 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 (*RadicalLogger) Alert ¶
func (bl *RadicalLogger) Alert(format string, v ...interface{})
Alert Log ALERT level message.
func (*RadicalLogger) Async ¶
func (bl *RadicalLogger) Async(msgLen ...int64) *RadicalLogger
Async set the log to asynchronous and start the goroutine
func (*RadicalLogger) Close ¶
func (bl *RadicalLogger) Close()
Close close logger, flush all chan data and destroy all adapters in RadicalLogger.
func (*RadicalLogger) Critical ¶
func (bl *RadicalLogger) Critical(format string, v ...interface{})
Critical Log CRITICAL level message.
func (*RadicalLogger) Debug ¶
func (bl *RadicalLogger) Debug(format string, v ...interface{})
Debug Log DEBUG level message.
func (*RadicalLogger) DelLogger ¶
func (bl *RadicalLogger) DelLogger(adapterName string) error
DelLogger remove a logger adapter in RadicalLogger.
func (*RadicalLogger) Emergency ¶
func (bl *RadicalLogger) Emergency(format string, v ...interface{})
Emergency Log EMERGENCY level message.
func (*RadicalLogger) EnableFuncCallDepth ¶
func (bl *RadicalLogger) EnableFuncCallDepth(b bool)
EnableFuncCallDepth enable log funcCallDepth
func (*RadicalLogger) Error ¶
func (bl *RadicalLogger) Error(format string, v ...interface{})
Error Log ERROR level message.
func (*RadicalLogger) GetLevel ¶
func (bl *RadicalLogger) GetLevel() int
GetLevel Get Current log message level.
func (*RadicalLogger) GetLogFuncCallDepth ¶
func (bl *RadicalLogger) GetLogFuncCallDepth() int
GetLogFuncCallDepth return log funcCallDepth for wrapper
func (*RadicalLogger) Info ¶
func (bl *RadicalLogger) Info(format string, v ...interface{})
Info Log INFO level message. compatibility alias for Informational()
func (*RadicalLogger) Informational ¶
func (bl *RadicalLogger) Informational(format string, v ...interface{})
Informational Log INFORMATIONAL level message.
func (*RadicalLogger) Notice ¶
func (bl *RadicalLogger) Notice(format string, v ...interface{})
Notice Log NOTICE level message.
func (*RadicalLogger) Reset ¶
func (bl *RadicalLogger) Reset()
Reset close all outputs, and set bl.outputs to nil
func (*RadicalLogger) SetLevel ¶
func (bl *RadicalLogger) 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 (*RadicalLogger) SetLogFuncCallDepth ¶
func (bl *RadicalLogger) SetLogFuncCallDepth(d int)
SetLogFuncCallDepth set log funcCallDepth
func (*RadicalLogger) SetLogger ¶
func (bl *RadicalLogger) SetLogger(adapterName string, configs ...string) error
SetLogger provides a given logger adapter into RadicalLogger with config string. config need to be correct JSON as string: {"interval":360}.
func (*RadicalLogger) Trace ¶
func (bl *RadicalLogger) Trace(format string, v ...interface{})
Trace Log TRACE level message. compatibility alias for Debug()
func (*RadicalLogger) Warn ¶
func (bl *RadicalLogger) Warn(format string, v ...interface{})
Warn Log WARN level message. compatibility alias for Warning()
func (*RadicalLogger) Warning ¶
func (bl *RadicalLogger) Warning(format string, v ...interface{})
Warning Log WARNING level message.