castor/logger.go

33 lines
535 B
Go

package main
import "log"
// Logger has just two levels: info and debug
type Logger interface {
Info(...interface{})
Debug(...interface{})
}
// NewLogger returns a logger that has just two levels: info and debug
func NewLogger(log *log.Logger, debug bool) Logger {
return &l{
logger: log,
debug: debug,
}
}
type l struct {
logger *log.Logger
debug bool
}
func (l *l) Info(s ...interface{}) {
l.logger.Println("INFO", s[:])
}
func (l *l) Debug(s ...interface{}) {
if l.debug {
l.logger.Println("DEBUG", s[:])
}
}