Documentation ¶
Index ¶
- Constants
- func Register(name string, log loggerType)
- type 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) EnableFuncCallDepth(b bool)
- func (bl *BeeLogger) Error(format string, v ...interface{})
- func (bl *BeeLogger) Fatal(format string, v ...interface{})
- func (bl *BeeLogger) Flush()
- func (bl *BeeLogger) Info(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) StartLogger()
- func (bl *BeeLogger) Trace(format string, v ...interface{})
- func (bl *BeeLogger) Warn(format string, v ...interface{})
- type Brush
- type ConnWriter
- type ConsoleWriter
- type DatabaseWriter
- type FileLogWriter
- type Log
- type LoggerInterface
- type MuxWriter
- type SmtpWriter
Constants ¶
const ( // log message levels LevelTrace = iota LevelDebug LevelInfo LevelWarn LevelError LevelCritical LevelFatal )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BeeLogger ¶
type BeeLogger struct { Adapter string // 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 logger, flush all chan data and destroy all adapters in BeeLogger.
func (*BeeLogger) EnableFuncCallDepth ¶
enable log funcCallDepth
func (*BeeLogger) SetLevel ¶
set log message level. if message level (such as LevelTrace) is less than logger level (such as LevelWarn), ignore message.
func (*BeeLogger) 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}.
func (*BeeLogger) StartLogger ¶
func (bl *BeeLogger) StartLogger()
start logger chan reading. when chan is full, write logs.
type ConnWriter ¶
type ConnWriter struct { ReconnectOnMsg bool `json:"reconnectOnMsg"` Reconnect bool `json:"reconnect"` Net string `json:"net"` Addr string `json:"addr"` Level int `json:"level"` // contains filtered or unexported fields }
ConnWriter implements LoggerInterface. it writes messages in keep-live tcp connection.
func (*ConnWriter) Destroy ¶
func (c *ConnWriter) Destroy()
destroy connection writer and close tcp listener.
func (*ConnWriter) Init ¶
func (c *ConnWriter) Init(jsonconfig string) error
init connection writer with json config. json config only need key "level".
type ConsoleWriter ¶
type ConsoleWriter struct { Level int `json:"level"` // contains filtered or unexported fields }
ConsoleWriter implements LoggerInterface and writes messages to terminal.
func (*ConsoleWriter) Init ¶
func (c *ConsoleWriter) Init(jsonconfig string) error
init console logger. jsonconfig like '{"level":0}'.
type DatabaseWriter ¶
type DatabaseWriter struct { Driver string `json:"driver"` Conn string `json:"conn"` Level int `json:"level"` // contains filtered or unexported fields }
DatabaseWriter implements LoggerInterface and is used to log into database.
func (*DatabaseWriter) Init ¶
func (d *DatabaseWriter) Init(jsonconfig string) (err error)
init database writer with json config. config like:
{ "driver": "mysql" "conn":"root:root@tcp(127.0.0.1:3306)/gogs?charset=utf8", "level": 0 }
connection string is based on xorm.
type FileLogWriter ¶
type FileLogWriter struct { *log.Logger // The opened file Filename string `json:"filename"` Maxlines int `json:"maxlines"` // Rotate at size Maxsize int `json:"maxsize"` // Rotate daily Daily bool `json:"daily"` Maxdays int64 `json:"maxdays` Rotate bool `json:"rotate"` Level int `json:"level"` // contains filtered or unexported fields }
FileLogWriter implements LoggerInterface. It writes messages by lines limit, file size limit, or time frequency.
func (*FileLogWriter) Destroy ¶
func (w *FileLogWriter) Destroy()
destroy file logger, close file writer.
func (*FileLogWriter) DoRotate ¶
func (w *FileLogWriter) DoRotate() error
DoRotate means it need to write file in new file. new file name like xx.log.2013-01-01.2
func (*FileLogWriter) Flush ¶
func (w *FileLogWriter) Flush()
flush file logger. there are no buffering messages in file logger in memory. flush file means sync file from disk.
func (*FileLogWriter) Init ¶
func (w *FileLogWriter) Init(jsonconfig string) error
Init file logger with json config. jsonconfig like:
{ "filename":"logs/beego.log", "maxlines":10000, "maxsize":1<<30, "daily":true, "maxdays":15, "rotate":true }
func (*FileLogWriter) StartLogger ¶
func (w *FileLogWriter) StartLogger() error
start file logger. create log file and set to locker-inside file writer.
type LoggerInterface ¶
type LoggerInterface interface { Init(config string) error WriteMsg(msg string, level int) error Destroy() Flush() }
LoggerInterface defines the behavior of a log provider.
func NewConsole ¶
func NewConsole() LoggerInterface
create ConsoleWriter returning as LoggerInterface.
func NewDatabase ¶
func NewDatabase() LoggerInterface
func NewFileWriter ¶
func NewFileWriter() LoggerInterface
create a FileLogWriter returning as LoggerInterface.
type SmtpWriter ¶
type SmtpWriter struct { Username string `json:"Username"` Password string `json:"password"` Host string `json:"Host"` Subject string `json:"subject"` 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":"example@gmail.com", "password:"password", "host":"smtp.gmail.com:465", "subject":"email title", "sendTos":["email1","email2"], "level":LevelError }