Commit 417e8897 by yemin

no message

parent 416ace3a
package log
type LogConfig struct {
// Debug、Info、Warn、Error
LogLevel string
// true、false
LogColorful bool
LogResponseLength int
LogShowSql bool
LogIndexNamePrefix string
}
var LogConf = LogConfig{"Debug", true, 0, true, ""}
......@@ -9,18 +9,6 @@ import (
"time"
)
// Debug、Info、Warn、Error
var LogLevel = "DEBUG"
// true、false
var LogColorful = true
var LogResponseLength int
var LogShowSql = true
var LogIndexNamePrefix = ""
const (
LevelDebug = "Debug"
LevelInfo = "Info"
......@@ -36,7 +24,7 @@ func DebugDo(f func()) {
func IsDebug() bool {
ok := false
switch strings.ToLower(LogLevel) {
switch strings.ToLower(LogConf.LogLevel) {
case strings.ToLower(LevelDebug):
ok = true
break
......@@ -46,7 +34,7 @@ func IsDebug() bool {
func Debugf(format string, msg ...interface{}) {
ok := false
switch strings.ToLower(LogLevel) {
switch strings.ToLower(LogConf.LogLevel) {
case strings.ToLower(LevelDebug):
ok = true
break
......@@ -59,7 +47,7 @@ func Debugf(format string, msg ...interface{}) {
func Debug(msg interface{}) {
ok := false
switch strings.ToLower(LogLevel) {
switch strings.ToLower(LogConf.LogLevel) {
case strings.ToLower(LevelDebug):
ok = true
break
......@@ -72,7 +60,7 @@ func Debug(msg interface{}) {
func Infof(format string, msg ...interface{}) {
ok := false
switch strings.ToLower(LogLevel) {
switch strings.ToLower(LogConf.LogLevel) {
case strings.ToLower(LevelDebug):
ok = true
break
......@@ -88,7 +76,7 @@ func Infof(format string, msg ...interface{}) {
func Info(msg interface{}) {
ok := false
switch strings.ToLower(LogLevel) {
switch strings.ToLower(LogConf.LogLevel) {
case strings.ToLower(LevelDebug):
ok = true
break
......@@ -104,7 +92,7 @@ func Info(msg interface{}) {
func Warnf(format string, msg ...interface{}) {
ok := false
switch strings.ToLower(LogLevel) {
switch strings.ToLower(LogConf.LogLevel) {
case strings.ToLower(LevelDebug):
ok = true
break
......@@ -123,7 +111,7 @@ func Warnf(format string, msg ...interface{}) {
func Warn(msg interface{}) {
ok := false
switch strings.ToLower(LogLevel) {
switch strings.ToLower(LogConf.LogLevel) {
case strings.ToLower(LevelDebug):
ok = true
break
......@@ -142,7 +130,7 @@ func Warn(msg interface{}) {
func Errorf(format string, msg ...interface{}) {
ok := false
switch strings.ToLower(LogLevel) {
switch strings.ToLower(LogConf.LogLevel) {
case strings.ToLower(LevelDebug):
ok = true
break
......@@ -164,7 +152,7 @@ func Errorf(format string, msg ...interface{}) {
func Error(msg interface{}) {
ok := false
switch strings.ToLower(LogLevel) {
switch strings.ToLower(LogConf.LogLevel) {
case strings.ToLower(LevelDebug):
ok = true
break
......@@ -202,7 +190,7 @@ const (
func print(tag, file string, line int, msg interface{}) {
str := "%s %s [%d] %s %d %s"
if LogColorful {
if LogConf.LogColorful {
switch tag {
case LevelDebug:
str = "%s %s [%d] %s %d " + green + "%s" + reset
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment