1
0
mirror of https://github.com/labstack/echo.git synced 2025-03-17 21:08:05 +02:00
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2016-03-06 09:04:04 -08:00
parent e4f3900c40
commit d6af11ec08
2 changed files with 19 additions and 31 deletions

42
echo.go
View File

@ -60,28 +60,10 @@ type (
debug bool
hook http.HandlerFunc
autoIndex bool
logger Logger
logger *log.Logger
router *Router
}
// Logger is the interface that declares echo's logging system.
Logger interface {
Debug(...interface{})
Debugf(string, ...interface{})
Info(...interface{})
Infof(string, ...interface{})
Warn(...interface{})
Warnf(string, ...interface{})
Error(...interface{})
Errorf(string, ...interface{})
Fatal(...interface{})
Fatalf(string, ...interface{})
}
// Route contains a handler and information for matching against requests.
Route struct {
Method string
@ -242,6 +224,7 @@ func New() (e *Echo) {
// Logger
e.logger = log.New("echo")
e.SetLogLevel(log.FATAL)
return
}
@ -251,13 +234,23 @@ func (e *Echo) Router() *Router {
return e.router
}
// SetLogger sets the logger instance.
func (e *Echo) SetLogger(logger Logger) {
e.logger = logger
// SetLogPrefix sets the prefix for the logger. Default value is `echo`.
func (e *Echo) SetLogPrefix(prefix string) {
e.logger.SetPrefix(prefix)
}
// SetLogOutput sets the output destination for the logger. Default value is `os.Std*`
func (e *Echo) SetLogOutput(w io.Writer) {
e.logger.SetOutput(w)
}
// SetLogLevel sets the log level for the logger. Default value is `log.FATAL`.
func (e *Echo) SetLogLevel(l log.Level) {
e.logger.SetLevel(l)
}
// Logger returns the logger instance.
func (e *Echo) Logger() Logger {
func (e *Echo) Logger() *log.Logger {
return e.logger
}
@ -275,7 +268,7 @@ func (e *Echo) DefaultHTTPErrorHandler(err error, c *Context) {
if !c.response.committed {
http.Error(c.response, msg, code)
}
e.logger.Error(err)
e.logger.Debug(err)
}
// SetHTTPErrorHandler registers a custom Echo.HTTPErrorHandler.
@ -296,6 +289,7 @@ func (e *Echo) SetRenderer(r Renderer) {
// SetDebug enable/disable debug mode.
func (e *Echo) SetDebug(on bool) {
e.debug = on
e.SetLogLevel(log.FATAL)
}
// Debug returns debug mode (enabled or disabled).

View File

@ -41,13 +41,7 @@ SetLogOutput sets the output destination for the logger. Default value is `os.St
`echo#SetLogLevel(l log.Level)`
SetLogLevel sets the log level for the logger. Default value is `log.INFO`.
### HTTP2
`echo#HTTP2(on bool)`
Enable/disable HTTP2 support.
SetLogLevel sets the log level for the logger. Default value is `log.FATAL`.
### Auto index