summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-05-14 15:04:07 +0800
committerLauris BH <lauris@nix.lv>2019-05-14 10:04:07 +0300
commit8b36f01f453979d6b6ee14f9ac6e56fa6c7b035e (patch)
treeb0f38d5a757aaaa10484241f85a77bf936084815 /modules
parent0e057eb0336629652ae8e661b1bd497007730334 (diff)
downloadgitea-8b36f01f453979d6b6ee14f9ac6e56fa6c7b035e.tar.gz
gitea-8b36f01f453979d6b6ee14f9ac6e56fa6c7b035e.zip
Move xorm logger bridge from log to models so that log module could be a standalone package (#6944)
* move xorm logger bridge from log to models so that log module could be a standalone package * fix tests * save logger on xorm log bridge
Diffstat (limited to 'modules')
-rw-r--r--modules/log/xorm.go112
-rw-r--r--modules/setting/log.go3
2 files changed, 0 insertions, 115 deletions
diff --git a/modules/log/xorm.go b/modules/log/xorm.go
deleted file mode 100644
index c08b7fd7d5..0000000000
--- a/modules/log/xorm.go
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright 2017 The Gitea Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-package log
-
-import (
- "fmt"
-
- "github.com/go-xorm/core"
-)
-
-// XORMLogBridge a logger bridge from Logger to xorm
-type XORMLogBridge struct {
- showSQL bool
- level core.LogLevel
-}
-
-var (
- // XORMLogger the logger for xorm
- XORMLogger *XORMLogBridge
-)
-
-// InitXORMLogger inits a log bridge for xorm
-func InitXORMLogger(showSQL bool) {
- XORMLogger = &XORMLogBridge{
- showSQL: showSQL,
- }
-}
-
-// GetGiteaLevel returns the minimum Gitea logger level
-func (l *XORMLogBridge) GetGiteaLevel() Level {
- return GetLogger("xorm").GetLevel()
-}
-
-// Log a message with defined skip and at logging level
-func (l *XORMLogBridge) Log(skip int, level Level, format string, v ...interface{}) error {
- return GetLogger("xorm").Log(skip+1, level, format, v...)
-}
-
-// Debug show debug log
-func (l *XORMLogBridge) Debug(v ...interface{}) {
- l.Log(2, DEBUG, fmt.Sprint(v...))
-}
-
-// Debugf show debug log
-func (l *XORMLogBridge) Debugf(format string, v ...interface{}) {
- l.Log(2, DEBUG, format, v...)
-}
-
-// Error show error log
-func (l *XORMLogBridge) Error(v ...interface{}) {
- l.Log(2, ERROR, fmt.Sprint(v...))
-}
-
-// Errorf show error log
-func (l *XORMLogBridge) Errorf(format string, v ...interface{}) {
- l.Log(2, ERROR, format, v...)
-}
-
-// Info show information level log
-func (l *XORMLogBridge) Info(v ...interface{}) {
- l.Log(2, INFO, fmt.Sprint(v...))
-}
-
-// Infof show information level log
-func (l *XORMLogBridge) Infof(format string, v ...interface{}) {
- l.Log(2, INFO, format, v...)
-}
-
-// Warn show warning log
-func (l *XORMLogBridge) Warn(v ...interface{}) {
- l.Log(2, WARN, fmt.Sprint(v...))
-}
-
-// Warnf show warnning log
-func (l *XORMLogBridge) Warnf(format string, v ...interface{}) {
- l.Log(2, WARN, format, v...)
-}
-
-// Level get logger level
-func (l *XORMLogBridge) Level() core.LogLevel {
- switch l.GetGiteaLevel() {
- case TRACE, DEBUG:
- return core.LOG_DEBUG
- case INFO:
- return core.LOG_INFO
- case WARN:
- return core.LOG_WARNING
- case ERROR, CRITICAL:
- return core.LOG_ERR
- }
- return core.LOG_OFF
-}
-
-// SetLevel set the logger level
-func (l *XORMLogBridge) SetLevel(lvl core.LogLevel) {
-}
-
-// ShowSQL set if record SQL
-func (l *XORMLogBridge) ShowSQL(show ...bool) {
- if len(show) > 0 {
- l.showSQL = show[0]
- } else {
- l.showSQL = true
- }
-}
-
-// IsShowSQL if record SQL
-func (l *XORMLogBridge) IsShowSQL() bool {
- return l.showSQL
-}
diff --git a/modules/setting/log.go b/modules/setting/log.go
index cd2c5cc8c1..43a28309d2 100644
--- a/modules/setting/log.go
+++ b/modules/setting/log.go
@@ -295,8 +295,5 @@ func NewXORMLogService(disableConsole bool) {
Cfg.Section("log").Key("XORM").MustString(",")
generateNamedLogger("xorm", options)
- log.InitXORMLogger(LogSQL)
- } else {
- log.InitXORMLogger(false)
}
}