start big refactoring

This commit is contained in:
Dominic Breuker
2018-02-20 19:33:03 +01:00
parent e8a69a3997
commit a517fe25de
5 changed files with 149 additions and 4 deletions

37
internal/logger/logger.go Normal file
View File

@@ -0,0 +1,37 @@
package logger
import (
"log"
"os"
)
// Logger is the logger used to print to the command line
type Logger struct {
infoLogger *log.Logger
errorLogger *log.Logger
eventLogger *log.Logger
}
// NewLogger creates a new logger instance
func NewLogger() *Logger {
return &Logger{
infoLogger: log.New(os.Stdout, "", 0),
errorLogger: log.New(os.Stderr, "", 0),
eventLogger: log.New(os.Stdout, "", log.Ldate|log.Ltime),
}
}
// Infof writes an info message to stdout
func (l *Logger) Infof(format string, v ...interface{}) {
l.infoLogger.Printf(format, v...)
}
// Errorf writes an error message to stderr
func (l *Logger) Errorf(format string, v ...interface{}) {
l.errorLogger.Printf(format, v...)
}
// Eventf writes an event with timestamp to stdout
func (l *Logger) Eventf(format string, v ...interface{}) {
l.eventLogger.Printf(format, v...)
}