2015-03-30 09:55:03 -07:00
|
|
|
package authboss
|
|
|
|
|
|
|
|
import (
|
2016-05-07 02:12:20 -04:00
|
|
|
"io"
|
2015-03-30 09:55:03 -07:00
|
|
|
"log"
|
2016-05-07 02:12:20 -04:00
|
|
|
"net/http"
|
2015-03-30 09:55:03 -07:00
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
// DefaultLogger is a basic logger.
|
|
|
|
type DefaultLogger log.Logger
|
|
|
|
|
2016-05-07 02:12:20 -04:00
|
|
|
// LogWriteMaker is used to create a logger from an http request.
|
|
|
|
type LogWriteMaker func(http.ResponseWriter, *http.Request) io.Writer
|
|
|
|
|
2015-03-30 09:55:03 -07:00
|
|
|
// NewDefaultLogger creates a logger to stdout.
|
|
|
|
func NewDefaultLogger() *DefaultLogger {
|
|
|
|
return ((*DefaultLogger)(log.New(os.Stdout, "", log.LstdFlags)))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write writes to the internal logger.
|
|
|
|
func (d *DefaultLogger) Write(b []byte) (int, error) {
|
|
|
|
((*log.Logger)(d)).Printf("%s", b)
|
|
|
|
return len(b), nil
|
|
|
|
}
|