调用log4go包

Signed-off-by: dmy@lab <dmy@lab.com>
This commit is contained in:
dmy@lab
2015-10-16 23:21:38 +08:00
parent 70b9ed78ea
commit 74de3d715f
5 changed files with 37 additions and 26 deletions

View File

@@ -1,8 +1,8 @@
package log
import (
log "github.com/alecthomas/log4go"
"fmt"
log "github.com/alecthomas/log4go"
)
var root log.Logger = make(log.Logger)
@@ -54,6 +54,7 @@ type Logger interface {
Info(string, ...interface{})
Warn(string, ...interface{}) error
Error(string, ...interface{}) error
Panic(string, ...interface{})
}
type PrefixLogger struct {
@@ -91,6 +92,10 @@ func (pl *PrefixLogger) Error(arg0 string, args ...interface{}) error {
return pl.Logger.Error(pl.pfx(arg0), args...)
}
func (pl *PrefixLogger) Panic(arg0 string, args ...interface{}) {
panic(pl.Error(arg0, args))
}
func (pl *PrefixLogger) AddLogPrefix(prefix string) {
if len(pl.prefix) > 0 {
pl.prefix += " "
@@ -118,4 +123,8 @@ func Warn(arg0 string, args ...interface{}) error {
func Error(arg0 string, args ...interface{}) error {
return root.Error(arg0, args...)
}
}
func Panic(arg0 string, args ...interface{}) error {
panic(root.Error(arg0, args...))
}