This commit is contained in:
fatedier 2019-01-31 16:54:46 +08:00
parent 48990da22e
commit bbab3fe9ca
2 changed files with 5 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import (
"github.com/fatedier/beego/logs" "github.com/fatedier/beego/logs"
) )
// Log is the under log object
var Log *logs.BeeLogger var Log *logs.BeeLogger
func init() { func init() {
@ -33,6 +34,7 @@ func InitLog(logWay string, logFile string, logLevel string, maxdays int64) {
SetLogLevel(logLevel) SetLogLevel(logLevel)
} }
// SetLogFile to configure log params
// logWay: file or console // logWay: file or console
func SetLogFile(logWay string, logFile string, maxdays int64) { func SetLogFile(logWay string, logFile string, maxdays int64) {
if logWay == "console" { if logWay == "console" {
@ -43,6 +45,7 @@ func SetLogFile(logWay string, logFile string, maxdays int64) {
} }
} }
// SetLogLevel set log level, default is warning
// value: error, warning, info, debug, trace // value: error, warning, info, debug, trace
func SetLogLevel(logLevel string) { func SetLogLevel(logLevel string) {
level := 4 // warning level := 4 // warning
@ -85,7 +88,7 @@ func Trace(format string, v ...interface{}) {
Log.Trace(format, v...) Log.Trace(format, v...)
} }
// Logger // Logger is the log interface
type Logger interface { type Logger interface {
AddLogPrefix(string) AddLogPrefix(string)
GetPrefixStr() string GetPrefixStr() string

View File

@ -31,6 +31,7 @@ type WebsocketListener struct {
httpMutex *http.ServeMux httpMutex *http.ServeMux
} }
// NewWebsocketListener to handle websocket connections
// ln: tcp listener for websocket connections // ln: tcp listener for websocket connections
func NewWebsocketListener(ln net.Listener) (wl *WebsocketListener) { func NewWebsocketListener(ln net.Listener) (wl *WebsocketListener) {
wl = &WebsocketListener{ wl = &WebsocketListener{