aboutsummaryrefslogtreecommitdiff
path: root/modules/log
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2014-06-28 15:00:32 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2014-06-28 15:00:32 +0800
commita357cda9575b482004329e81f0add6e4c32ab02a (patch)
treedb7d7508a039cfd4dd6cedad236e720bcfe1396c /modules/log
parent165e3e8f18bb7d38722d0c836ddbf8c95023cf67 (diff)
parent6e448b07145fbb090e0da6deb97f244c2bfd7ba7 (diff)
Merge branch 'dev' of github.com:gogits/gogs into dev
Diffstat (limited to 'modules/log')
-rw-r--r--modules/log/log.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/modules/log/log.go b/modules/log/log.go
index f83ec0ad..24f0442d 100644
--- a/modules/log/log.go
+++ b/modules/log/log.go
@@ -6,13 +6,16 @@
package log
import (
+ "fmt"
"os"
+ "path"
"github.com/gogits/logs"
)
var (
- loggers []*logs.BeeLogger
+ loggers []*logs.BeeLogger
+ GitLogger *logs.BeeLogger
)
func init() {
@@ -33,7 +36,15 @@ func NewLogger(bufLen int64, mode, config string) {
loggers = append(loggers, logger)
}
logger.SetLogFuncCallDepth(3)
- logger.SetLogger(mode, config)
+ if err := logger.SetLogger(mode, config); err != nil {
+ Fatal("Fail to set logger(%s): %v", mode, err)
+ }
+}
+
+func NewGitLogger(logPath string) {
+ os.MkdirAll(path.Dir(logPath), os.ModePerm)
+ GitLogger = logs.NewLogger(0)
+ GitLogger.SetLogger("file", fmt.Sprintf(`{"level":0,"filename":"%s","rotate":false}`, logPath))
}
func Trace(format string, v ...interface{}) {