marion 5 years ago
parent
commit
7103e73b9a
2 changed files with 19 additions and 20 deletions
  1. 0 1
      go.mod
  2. 19 19
      utils/logger/xorm_logger.go

+ 0 - 1
go.mod

@@ -27,6 +27,5 @@ require (
 	golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e
 	golang.org/x/text v0.3.2
 	gopkg.in/gemnasium/logrus-graylog-hook.v2 v2.0.7
-	xorm.io/core v0.7.3
 	xorm.io/xorm v1.0.1
 )

+ 19 - 19
utils/logger/xorm_logger.go

@@ -2,28 +2,28 @@ package logger
 
 import (
 	"github.com/sirupsen/logrus"
-	"xorm.io/core"
+	"xorm.io/xorm/log"
 )
 
 type XORMLogger struct {
 	logger  *Logger
-	level   core.LogLevel
+	level   log.LogLevel
 	showSQL bool
 }
 
-func NewXORMLogger(logger *Logger) core.ILogger {
+func NewXORMLogger(logger *Logger) log.Logger {
 	lg := &XORMLogger{logger: logger.WithField("lib", "xorm"), showSQL: true}
-	level := core.LOG_INFO
+	level := log.LOG_INFO
 	if logger.Level == logrus.WarnLevel {
-		level = core.LOG_WARNING
+		level = log.LOG_WARNING
 	} else if logger.Level == logrus.DebugLevel {
-		level = core.LOG_DEBUG
+		level = log.LOG_DEBUG
 	} else if logger.Level == logrus.ErrorLevel {
-		level = core.LOG_ERR
+		level = log.LOG_ERR
 	} else if logger.Level == logrus.FatalLevel {
-		level = core.LOG_OFF
+		level = log.LOG_OFF
 	} else if logger.Level == logrus.PanicLevel {
-		level = core.LOG_UNKNOWN
+		level = log.LOG_UNKNOWN
 	}
 	lg.level = level
 	return lg
@@ -47,7 +47,7 @@ func (s *XORMLogger) printSql(v ...interface{}) {
 
 // Error implement core.ILogger
 func (s *XORMLogger) Error(v ...interface{}) {
-	if s.level <= core.LOG_ERR {
+	if s.level <= log.LOG_ERR {
 		s.printSql(v...)
 	}
 	return
@@ -55,7 +55,7 @@ func (s *XORMLogger) Error(v ...interface{}) {
 
 // Errorf implement core.ILogger
 func (s *XORMLogger) Errorf(format string, v ...interface{}) {
-	if s.level <= core.LOG_ERR {
+	if s.level <= log.LOG_ERR {
 		s.printSql(v...)
 	}
 	return
@@ -63,7 +63,7 @@ func (s *XORMLogger) Errorf(format string, v ...interface{}) {
 
 // Debug implement core.ILogger
 func (s *XORMLogger) Debug(v ...interface{}) {
-	if s.level <= core.LOG_DEBUG {
+	if s.level <= log.LOG_DEBUG {
 		s.printSql(v...)
 	}
 	return
@@ -71,7 +71,7 @@ func (s *XORMLogger) Debug(v ...interface{}) {
 
 // Debugf implement core.ILogger
 func (s *XORMLogger) Debugf(format string, v ...interface{}) {
-	if s.level <= core.LOG_DEBUG {
+	if s.level <= log.LOG_DEBUG {
 		s.printSql(v...)
 	}
 	return
@@ -79,7 +79,7 @@ func (s *XORMLogger) Debugf(format string, v ...interface{}) {
 
 // Info implement core.ILogger
 func (s *XORMLogger) Info(v ...interface{}) {
-	if s.level <= core.LOG_INFO {
+	if s.level <= log.LOG_INFO {
 		s.printSql(v...)
 	}
 	return
@@ -87,7 +87,7 @@ func (s *XORMLogger) Info(v ...interface{}) {
 
 // Infof implement core.ILogger
 func (s *XORMLogger) Infof(format string, v ...interface{}) {
-	if s.level <= core.LOG_INFO {
+	if s.level <= log.LOG_INFO {
 		s.printSql(v...)
 	}
 	return
@@ -95,7 +95,7 @@ func (s *XORMLogger) Infof(format string, v ...interface{}) {
 
 // Warn implement core.ILogger
 func (s *XORMLogger) Warn(v ...interface{}) {
-	if s.level <= core.LOG_WARNING {
+	if s.level <= log.LOG_WARNING {
 		s.printSql(v...)
 	}
 	return
@@ -103,19 +103,19 @@ func (s *XORMLogger) Warn(v ...interface{}) {
 
 // Warnf implement core.ILogger
 func (s *XORMLogger) Warnf(format string, v ...interface{}) {
-	if s.level <= core.LOG_WARNING {
+	if s.level <= log.LOG_WARNING {
 		s.printSql(v...)
 	}
 	return
 }
 
 // Level implement core.ILogger
-func (s *XORMLogger) Level() core.LogLevel {
+func (s *XORMLogger) Level() log.LogLevel {
 	return s.level
 }
 
 // SetLevel implement core.ILogger
-func (s *XORMLogger) SetLevel(l core.LogLevel) {
+func (s *XORMLogger) SetLevel(l log.LogLevel) {
 	s.level = l
 	return
 }