# README
logs
logs is a Go logs manager. It can use many logs adapters. The repo is inspired by database/sql
.
How to install?
go get github.com/astaxie/beego/logs
What adapters are supported?
As of now this logs support console, file,smtp and conn.
How to use it?
First you must import it
import (
"github.com/astaxie/beego/logs"
)
Then init a Log (example with console adapter)
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")
File adapter
Configure file adapter like this:
log := NewLogger(10000)
log.SetLogger("file", `{"filename":"test.log"}`)
Conn adapter
Configure like this:
log := NewLogger(1000)
log.SetLogger("conn", `{"net":"tcp","addr":":7020"}`)
log.Info("info")
Smtp adapter
Configure like this:
log := NewLogger(10000)
log.SetLogger("smtp", `{"username":"[email protected]","password":"xxxxxxxx","host":"smtp.gmail.com:587","sendTos":["[email protected]"]}`)
log.Critical("sendmail critical")
time.Sleep(time.Second * 30)
# Functions
Alert logs a message at alert level.
Async set the beelogger with Async mode and hold msglen messages.
ColorByMethod return color by http code GET return Blue POST return Cyan PUT return Yellow DELETE return Red PATCH return Green HEAD return Magenta OPTIONS return WHITE.
ColorByStatus return color by http code 2xx return Green 3xx return White 4xx return Yellow 5xx return Red.
Critical logs a message at critical level.
Debug logs a message at debug level.
Emergency logs a message at emergency level.
EnableFuncCallDepth enable log funcCallDepth.
Error logs a message at error level.
GetBeeLogger returns the default BeeLogger.
GetCallStack returns the current call stack information as a string.
GetLogger returns the default BeeLogger.
Info compatibility alias for Warning().
Informational logs a message at info level.
NewAnsiColorWriter creates and initializes a new ansiColorWriter using io.Writer w as its initial contents.
NewConn create new ConnWrite returning as LoggerInterface.
NewConsole create ConsoleWriter returning as LoggerInterface.
newFileWriter create a FileLogWriter returning as LoggerInterface.
NewLogger returns a new BeeLogger.
NewModeAnsiColorWriter create and initializes a new ansiColorWriter by specifying the outputMode.
Notice logs a message at notice level.
Register makes a log provide available by the provided name.
Reset will remove all the adapter.
SetLevel sets the global log level used by the simple logger.
SetLogFuncCall set the CallDepth, default is 4.
SetLogFuncCallDepth set log funcCallDepth.
SetLogger sets a new logger.
Trace logs a message at trace level.
W32Debug Helper method to output colored logs in Windows terminals.
Warn compatibility alias for Warning().
Warning logs a message at warning level.
# Constants
Name for adapter with beego official support.
Name for adapter with beego official support.
Name for adapter with beego official support.
Name for adapter with beego official support.
Name for adapter with beego official support.
Name for adapter with beego official support.
Name for adapter with beego official support.
Name for adapter with beego official support.
Name for adapter with beego official support.
DiscardNonColorEscSeq supports the divided color escape sequence.
RFC5424 log message levels.
RFC5424 log message levels.
RFC5424 log message levels.
RFC5424 log message levels.
RFC5424 log message levels.
Legacy log level constants to ensure backwards compatibility.
RFC5424 log message levels.
RFC5424 log message levels.
Legacy log level constants to ensure backwards compatibility.
Legacy log level constants to ensure backwards compatibility.
RFC5424 log message levels.
DiscardNonColorEscSeq supports the divided color escape sequence.
# Structs
BeeLogger is default logger in beego application.
SLACKWriter implements beego LoggerInterface and is used to send jiaoliao webhook.
JLWriter implements beego LoggerInterface and is used to send jiaoliao webhook.
SLACKWriter implements beego LoggerInterface and is used to send jiaoliao webhook.
SMTPWriter implements LoggerInterface and is used to send emails via given SMTP-server.
# Interfaces
Logger defines the behavior of a log provider.