1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 22:50:55 +00:00
Beego/log.go

85 lines
1.8 KiB
Go
Raw Normal View History

2014-04-12 05:18:18 +00:00
// Beego (http://beego.me/)
2014-06-25 02:39:37 +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-06-25 02:39:37 +00:00
2014-04-12 05:18:18 +00:00
// @link http://github.com/astaxie/beego for the canonical source repository
2014-06-25 02:39:37 +00:00
2014-04-12 05:18:18 +00:00
// @license http://github.com/astaxie/beego/blob/master/LICENSE
2014-06-25 02:39:37 +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 (
LevelTrace = iota
LevelDebug
LevelInfo
LevelWarning
LevelError
LevelCritical
)
// SetLogLevel sets the global log level used by the simple
// logger.
func SetLevel(l int) {
BeeLogger.SetLevel(l)
}
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
}
// Trace logs a message at trace level.
func Trace(v ...interface{}) {
BeeLogger.Trace(generateFmtStr(len(v)), v...)
}
// Debug logs a message at debug level.
func Debug(v ...interface{}) {
BeeLogger.Debug(generateFmtStr(len(v)), v...)
}
// Info logs a message at info level.
func Info(v ...interface{}) {
BeeLogger.Info(generateFmtStr(len(v)), v...)
}
// Warning logs a message at warning level.
func Warn(v ...interface{}) {
BeeLogger.Warn(generateFmtStr(len(v)), v...)
}
// Error logs a message at error level.
func Error(v ...interface{}) {
BeeLogger.Error(generateFmtStr(len(v)), v...)
}
// Critical logs a message at critical level.
func Critical(v ...interface{}) {
BeeLogger.Critical(generateFmtStr(len(v)), v...)
}
func generateFmtStr(n int) string {
return strings.Repeat("%v ", n)
}