Exemple #1
0
// New creates an instance of Echo.
func New() (e *Echo) {
	e = &Echo{maxParam: new(int)}
	e.pool.New = func() interface{} {
		return NewContext(nil, new(Response), e)
	}
	e.router = NewRouter(e)

	//----------
	// Defaults
	//----------

	e.HTTP2(true)
	e.defaultHTTPErrorHandler = func(err error, c *Context) {
		code := http.StatusInternalServerError
		msg := http.StatusText(code)
		if he, ok := err.(*HTTPError); ok {
			code = he.code
			msg = he.message
		}
		if e.debug {
			msg = err.Error()
		}
		if !c.response.committed {
			http.Error(c.response, msg, code)
		}
		log.Error(err)
	}
	e.SetHTTPErrorHandler(e.defaultHTTPErrorHandler)
	e.SetBinder(&binder{})

	// Logger
	log.SetPrefix("echo")
	log.SetLevel(log.INFO)

	return
}
Exemple #2
0
// SetLogLevel sets the log level for global logger. The default value is `log.INFO`.
func SetLogLevel(l log.Level) {
	log.SetLevel(l)
}