github.com/volatiletech/authboss@v2.4.1+incompatible/defaults/logger.go (about) 1 package defaults 2 3 import ( 4 "fmt" 5 "io" 6 "time" 7 ) 8 9 // Logger writes exactly once for each log line to underlying io.Writer 10 // that's passed in and ends each message with a newline. 11 // It has RFC3339 as a date format, and emits a log level. 12 type Logger struct { 13 Writer io.Writer 14 } 15 16 // NewLogger creates a new logger from an io.Writer 17 func NewLogger(writer io.Writer) Logger { 18 return Logger{Writer: writer} 19 } 20 21 // Info logs go here 22 func (l Logger) Info(s string) { 23 fmt.Fprintf(l.Writer, "%s [INFO]: %s\n", time.Now().UTC().Format(time.RFC3339), s) 24 } 25 26 // Error logs go here 27 func (l Logger) Error(s string) { 28 fmt.Fprintf(l.Writer, "%s [EROR]: %s\n", time.Now().UTC().Format(time.RFC3339), s) 29 }