2016-10-20 20:30:53 +02:00
|
|
|
+++
|
|
|
|
title = "Customization"
|
|
|
|
description = "Customizing Echo"
|
2016-11-21 00:16:22 +02:00
|
|
|
[menu.main]
|
2016-10-20 20:30:53 +02:00
|
|
|
name = "Customization"
|
|
|
|
parent = "guide"
|
|
|
|
weight = 3
|
|
|
|
+++
|
|
|
|
|
2016-11-17 08:46:00 +02:00
|
|
|
## HTTP Error Handler
|
2016-10-20 20:30:53 +02:00
|
|
|
|
2016-12-11 08:05:41 +02:00
|
|
|
Default HTTP error handler sends an error as JSON with the following rules:
|
2016-10-20 20:30:53 +02:00
|
|
|
|
2016-12-11 08:05:41 +02:00
|
|
|
- If error is `Echo#HTTPError` it sends HTTP response with status code `HTTPError.Code`
|
2016-10-20 20:30:53 +02:00
|
|
|
and message `HTTPError.Message`.
|
2016-12-11 08:05:41 +02:00
|
|
|
- If error is `error` it sends HTTP response with status code `500 - Internal Server Error`
|
|
|
|
and message `error.Error()`.
|
|
|
|
- It logs the error.
|
2016-10-20 20:30:53 +02:00
|
|
|
|
2016-12-11 08:05:41 +02:00
|
|
|
You can set a custom HTTP error handler using `Echo#HTTPErrorHandler`.
|
2016-10-20 20:30:53 +02:00
|
|
|
|
2016-11-17 08:46:00 +02:00
|
|
|
## Debugging
|
2016-10-20 20:30:53 +02:00
|
|
|
|
2016-11-13 19:36:57 +02:00
|
|
|
`Echo#Debug` enables/disables debug mode.
|
2016-10-20 20:30:53 +02:00
|
|
|
|
2016-11-17 08:46:00 +02:00
|
|
|
## Logging
|
2016-10-20 20:30:53 +02:00
|
|
|
|
2016-11-17 08:46:00 +02:00
|
|
|
### Log Output
|
2016-10-20 20:30:53 +02:00
|
|
|
|
2016-11-13 19:36:57 +02:00
|
|
|
`Echo#Logger.SetOutput(io.Writer)` sets the output destination for the logger.
|
|
|
|
Default value `os.Stdout`
|
2016-10-20 20:30:53 +02:00
|
|
|
|
2016-11-13 19:36:57 +02:00
|
|
|
To completely disable logs use `Echo#Logger.SetOutput(io.Discard)` or `Echo#Logger.SetLevel(log.OFF)`
|
2016-10-20 20:30:53 +02:00
|
|
|
|
2016-11-17 08:46:00 +02:00
|
|
|
### Log Level
|
2016-10-20 20:30:53 +02:00
|
|
|
|
2016-11-13 19:36:57 +02:00
|
|
|
`Echo#Logger.SetLevel(log.Lvl)`
|
2016-10-20 20:30:53 +02:00
|
|
|
|
2016-11-13 19:36:57 +02:00
|
|
|
SetLogLevel sets the log level for the logger. Default value `OFF`.
|
2016-10-20 20:30:53 +02:00
|
|
|
Possible values:
|
|
|
|
|
2016-11-13 19:36:57 +02:00
|
|
|
- `DEBUG`
|
|
|
|
- `INFO`
|
|
|
|
- `WARN`
|
|
|
|
- `ERROR`
|
|
|
|
- `OFF`
|
2016-10-20 20:30:53 +02:00
|
|
|
|
2016-11-13 19:36:57 +02:00
|
|
|
You can also set a custom logger using `Echo#Logger`.
|