2012-12-15 15:53:19 +00:00
|
|
|
package beego
|
|
|
|
|
|
|
|
import (
|
2013-09-09 20:43:48 +00:00
|
|
|
"strings"
|
|
|
|
|
2013-09-09 16:17:49 +00:00
|
|
|
"github.com/astaxie/beego/logs"
|
2012-12-15 15:53:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Log levels to control the logging output.
|
|
|
|
const (
|
|
|
|
LevelTrace = iota
|
|
|
|
LevelDebug
|
|
|
|
LevelInfo
|
|
|
|
LevelWarning
|
|
|
|
LevelError
|
|
|
|
LevelCritical
|
|
|
|
)
|
|
|
|
|
|
|
|
// SetLogLevel sets the global log level used by the simple
|
|
|
|
// logger.
|
|
|
|
func SetLevel(l int) {
|
2013-09-09 16:17:49 +00:00
|
|
|
BeeLogger.SetLevel(l)
|
2013-06-24 15:24:18 +00:00
|
|
|
}
|
|
|
|
|
2012-12-15 15:53:19 +00:00
|
|
|
// logger references the used application logger.
|
2013-09-09 16:17:49 +00:00
|
|
|
var BeeLogger *logs.BeeLogger
|
2013-06-24 15:24:18 +00:00
|
|
|
|
2012-12-15 15:53:19 +00:00
|
|
|
// SetLogger sets a new logger.
|
2013-09-09 16:17:49 +00:00
|
|
|
func SetLogger(adaptername string, config string) {
|
|
|
|
BeeLogger.SetLogger(adaptername, config)
|
2012-12-15 15:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Trace logs a message at trace level.
|
|
|
|
func Trace(v ...interface{}) {
|
2013-09-09 20:43:48 +00:00
|
|
|
BeeLogger.Trace(generateFmtStr(len(v)), v...)
|
2012-12-15 15:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Debug logs a message at debug level.
|
|
|
|
func Debug(v ...interface{}) {
|
2013-09-09 20:43:48 +00:00
|
|
|
BeeLogger.Debug(generateFmtStr(len(v)), v...)
|
2012-12-15 15:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Info logs a message at info level.
|
|
|
|
func Info(v ...interface{}) {
|
2013-09-09 20:43:48 +00:00
|
|
|
BeeLogger.Info(generateFmtStr(len(v)), v...)
|
2012-12-15 15:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Warning logs a message at warning level.
|
|
|
|
func Warn(v ...interface{}) {
|
2013-09-09 20:43:48 +00:00
|
|
|
BeeLogger.Warn(generateFmtStr(len(v)), v...)
|
2012-12-15 15:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Error logs a message at error level.
|
|
|
|
func Error(v ...interface{}) {
|
2013-09-09 20:43:48 +00:00
|
|
|
BeeLogger.Error(generateFmtStr(len(v)), v...)
|
2012-12-15 15:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Critical logs a message at critical level.
|
|
|
|
func Critical(v ...interface{}) {
|
2013-09-09 20:43:48 +00:00
|
|
|
BeeLogger.Critical(generateFmtStr(len(v)), v...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func generateFmtStr(n int) string {
|
|
|
|
return strings.Repeat("%v ", n)
|
2012-12-15 15:53:19 +00:00
|
|
|
}
|