Documentation
¶
Overview ¶
Package logs provide a general log interface Usage:
import "github.com/astaxie/beego/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
- func Register(name string, log loggerType)
- type BeeLogger
- func (bl *BeeLogger) Alert(format string, v ...interface{})
- func (bl *BeeLogger) Async() *BeeLogger
- func (bl *BeeLogger) Close()
- func (bl *BeeLogger) Critical(format string, v ...interface{})
- func (bl *BeeLogger) Debug(format string, v ...interface{})
- func (bl *BeeLogger) DelLogger(adaptername string) error
- func (bl *BeeLogger) Emergency(format string, v ...interface{})
- func (bl *BeeLogger) EnableFuncCallDepth(b bool)
- func (bl *BeeLogger) Error(format string, v ...interface{})
- func (bl *BeeLogger) Flush()
- func (bl *BeeLogger) GetLogFuncCallDepth() int
- func (bl *BeeLogger) Info(format string, v ...interface{})
- func (bl *BeeLogger) Informational(format string, v ...interface{})
- func (bl *BeeLogger) Notice(format string, v ...interface{})
- func (bl *BeeLogger) SetLevel(l int)
- func (bl *BeeLogger) SetLogFuncCallDepth(d int)
- func (bl *BeeLogger) SetLogger(adaptername string, config string) error
- func (bl *BeeLogger) Trace(format string, v ...interface{})
- func (bl *BeeLogger) Warn(format string, v ...interface{})
- func (bl *BeeLogger) Warning(format string, v ...interface{})
- type Logger
- type MuxWriter
- type SMTPWriter
Constants ¶
const ( LevelEmergency = iota LevelAlert LevelCritical LevelError LevelWarning LevelNotice LevelInformational LevelDebug )
RFC5424 log message levels.
const ( LevelInfo = LevelInformational LevelTrace = LevelDebug LevelWarn = LevelWarning )
Legacy loglevel constants to ensure backwards compatibility.
Deprecated: will be removed in 1.5.0.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BeeLogger ¶
type BeeLogger struct {
// contains filtered or unexported fields
}
BeeLogger is default logger in beego application. it can contain several providers and log message into all providers.
func NewLogger ¶
NewLogger returns a new BeeLogger. channellen means the number of messages in chan. if the buffering chan is full, logger adapters write to file or other way.
func (*BeeLogger) Close ¶
func (bl *BeeLogger) Close()
Close close logger, flush all chan data and destroy all adapters in BeeLogger.
func (*BeeLogger) EnableFuncCallDepth ¶
EnableFuncCallDepth enable log funcCallDepth
func (*BeeLogger) GetLogFuncCallDepth ¶
GetLogFuncCallDepth return log funcCallDepth for wrapper
func (*BeeLogger) Informational ¶
Informational Log INFORMATIONAL level message.
func (*BeeLogger) SetLevel ¶
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 ¶
SetLogFuncCallDepth set log funcCallDepth
func (*BeeLogger) SetLogger ¶
SetLogger provides a given logger adapter into BeeLogger with config string. config need to be correct JSON as string: {"interval":360}.
type Logger ¶
type Logger interface {
Init(config string) error
WriteMsg(msg string, level int) error
Destroy()
Flush()
}
Logger defines the behavior of a log provider.
func NewConsole ¶
func NewConsole() Logger
NewConsole create ConsoleWriter returning as LoggerInterface.
type SMTPWriter ¶
type SMTPWriter struct {
Username string `json:"username"`
Password string `json:"password"`
Host string `json:"host"`
Subject string `json:"subject"`
FromAddress string `json:"fromAddress"`
RecipientAddresses []string `json:"sendTos"`
Level int `json:"level"`
}
SMTPWriter implements LoggerInterface and is used to send emails via given SMTP-server.
func (*SMTPWriter) Init ¶
func (s *SMTPWriter) Init(jsonconfig string) error
Init smtp writer with json config. config like:
{
"Username":"[email protected]",
"password:"password",
"host":"smtp.gmail.com:465",
"subject":"email title",
"fromAddress":"[email protected]",
"sendTos":["email1","email2"],
"level":LevelError
}