2014-04-12 05:18:18 +00:00
|
|
|
// Beego (http://beego.me/)
|
2014-07-03 15:40:21 +00:00
|
|
|
//
|
2014-04-12 05:18:18 +00:00
|
|
|
// @description beego is an open-source, high-performance web framework for the Go programming language.
|
2014-07-03 15:40:21 +00:00
|
|
|
//
|
2014-04-12 05:18:18 +00:00
|
|
|
// @link http://github.com/astaxie/beego for the canonical source repository
|
2014-07-03 15:40:21 +00:00
|
|
|
//
|
2014-04-12 05:18:18 +00:00
|
|
|
// @license http://github.com/astaxie/beego/blob/master/LICENSE
|
2014-07-03 15:40:21 +00:00
|
|
|
//
|
2014-04-12 05:18:18 +00:00
|
|
|
// @authors astaxie
|
2013-12-23 03:46:11 +00:00
|
|
|
package beego
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/astaxie/beego/logs"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Log levels to control the logging output.
|
|
|
|
const (
|
2014-08-15 19:30:59 +00:00
|
|
|
LevelEmergency = iota
|
|
|
|
LevelAlert
|
2013-12-23 03:46:11 +00:00
|
|
|
LevelCritical
|
2014-08-15 19:30:59 +00:00
|
|
|
LevelError
|
|
|
|
LevelWarning
|
|
|
|
LevelNotice
|
|
|
|
LevelInformational
|
|
|
|
LevelDebug
|
2013-12-23 03:46:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// SetLogLevel sets the global log level used by the simple
|
|
|
|
// logger.
|
|
|
|
func SetLevel(l int) {
|
|
|
|
BeeLogger.SetLevel(l)
|
|
|
|
}
|
|
|
|
|
2014-03-25 16:06:25 +00:00
|
|
|
func SetLogFuncCall(b bool) {
|
|
|
|
BeeLogger.EnableFuncCallDepth(b)
|
|
|
|
BeeLogger.SetLogFuncCallDepth(3)
|
|
|
|
}
|
|
|
|
|
2013-12-23 03:46:11 +00:00
|
|
|
// logger references the used application logger.
|
|
|
|
var BeeLogger *logs.BeeLogger
|
|
|
|
|
|
|
|
// SetLogger sets a new logger.
|
2014-04-02 15:45:44 +00:00
|
|
|
func SetLogger(adaptername string, config string) error {
|
|
|
|
err := BeeLogger.SetLogger(adaptername, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
2013-12-23 03:46:11 +00:00
|
|
|
}
|
|
|
|
|
2014-08-15 19:30:59 +00:00
|
|
|
func Emergency(v ...interface{}) {
|
|
|
|
BeeLogger.Emergency(generateFmtStr(len(v)), v...)
|
2013-12-23 03:46:11 +00:00
|
|
|
}
|
|
|
|
|
2014-08-15 19:30:59 +00:00
|
|
|
func Alert(v ...interface{}) {
|
|
|
|
BeeLogger.Alert(generateFmtStr(len(v)), v...)
|
2013-12-23 03:46:11 +00:00
|
|
|
}
|
|
|
|
|
2014-08-15 19:30:59 +00:00
|
|
|
// Critical logs a message at critical level.
|
|
|
|
func Critical(v ...interface{}) {
|
|
|
|
BeeLogger.Critical(generateFmtStr(len(v)), v...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Error logs a message at error level.
|
|
|
|
func Error(v ...interface{}) {
|
|
|
|
BeeLogger.Error(generateFmtStr(len(v)), v...)
|
2013-12-23 03:46:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Warning logs a message at warning level.
|
2014-08-15 19:30:59 +00:00
|
|
|
func Warning(v ...interface{}) {
|
|
|
|
BeeLogger.Warning(generateFmtStr(len(v)), v...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Deprecated: compatibility alias for Warning(), Will be removed in 1.5.0.
|
2013-12-23 03:46:11 +00:00
|
|
|
func Warn(v ...interface{}) {
|
2014-08-15 19:30:59 +00:00
|
|
|
Warning(v...)
|
2013-12-23 03:46:11 +00:00
|
|
|
}
|
|
|
|
|
2014-08-15 19:30:59 +00:00
|
|
|
func Notice(v ...interface{}) {
|
|
|
|
BeeLogger.Notice(generateFmtStr(len(v)), v...)
|
2013-12-23 03:46:11 +00:00
|
|
|
}
|
|
|
|
|
2014-08-15 19:30:59 +00:00
|
|
|
// Info logs a message at info level.
|
|
|
|
func Informational(v ...interface{}) {
|
|
|
|
BeeLogger.Informational(generateFmtStr(len(v)), v...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Deprecated: compatibility alias for Warning(), Will be removed in 1.5.0.
|
|
|
|
func Info(v ...interface{}) {
|
|
|
|
Informational(v...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Debug logs a message at debug level.
|
|
|
|
func Debug(v ...interface{}) {
|
|
|
|
BeeLogger.Debug(generateFmtStr(len(v)), v...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Trace logs a message at trace level.
|
|
|
|
// Deprecated: compatibility alias for Warning(), Will be removed in 1.5.0.
|
|
|
|
func Trace(v ...interface{}) {
|
|
|
|
BeeLogger.Trace(generateFmtStr(len(v)), v...)
|
2013-12-23 03:46:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func generateFmtStr(n int) string {
|
|
|
|
return strings.Repeat("%v ", n)
|
|
|
|
}
|