1
0
mirror of https://github.com/volatiletech/authboss.git synced 2024-11-28 08:58:38 +02:00
authboss/defaults/logger.go

30 lines
693 B
Go
Raw Normal View History

package defaults
import (
"fmt"
"io"
"time"
)
// Logger writes exactly once for each log line to underlying io.Writer
// that's passed in and ends each message with a newline.
// It has RFC3339 as a date format, and emits a log level.
type Logger struct {
Writer io.Writer
}
// NewLogger creates a new logger from an io.Writer
func NewLogger(writer io.Writer) Logger {
return Logger{Writer: writer}
}
// Info logs go here
func (l Logger) Info(s string) {
fmt.Fprintf(l.Writer, "%s [INFO]: %s\n", time.Now().UTC().Format(time.RFC3339), s)
}
// Error logs go here
func (l Logger) Error(s string) {
fmt.Fprintf(l.Writer, "%s [EROR]: %s\n", time.Now().UTC().Format(time.RFC3339), s)
}