Commit 17dbeb3e authored by zauberstuhl's avatar zauberstuhl

Clean-up logger for new revel log interface

parent c5404482
...@@ -32,8 +32,7 @@ const ( ...@@ -32,8 +32,7 @@ const (
) )
var ( var (
logger Log logger Logger
defaultLogger Logger
defaultPrefix string defaultPrefix string
) )
...@@ -49,29 +48,29 @@ func init() { ...@@ -49,29 +48,29 @@ func init() {
} }
defaultPrefix = fmt.Sprintf("%s:%d %s ", file, line, f.Name()) defaultPrefix = fmt.Sprintf("%s:%d %s ", file, line, f.Name())
defaultLogger = log.New(os.Stdout, defaultPrefix, log.Lshortfile) logger = Logger{log.New(os.Stdout, defaultPrefix, log.Lshortfile)}
} }
type Logger interface { type LogWriter interface {
Println(v... interface{}) Println(v... interface{})
} }
type Log struct{ type Logger struct{
Logger LogWriter
} }
func SetLogger(logger Logger) { func SetLogger(writer LogWriter) {
defaultLogger = logger logger = Logger{writer}
} }
func (l Log) Info(values... interface{}) { func (l Logger) Info(values... interface{}) {
defaultLogger.Println(values...) l.Println(values...)
} }
func (l Log) Error(values... interface{}) { func (l Logger) Error(values... interface{}) {
l.Info(LOG_C_RED, values, LOG_C_RESET) l.Info(LOG_C_RED, values, LOG_C_RESET)
} }
func (l Log) Warn(values... interface{}) { func (l Logger) Warn(values... interface{}) {
l.Info(LOG_C_YELLOW, values, LOG_C_RESET) l.Info(LOG_C_YELLOW, values, LOG_C_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