mirror of
https://github.com/infinite-iroha/touka.git
synced 2026-02-03 17:01:11 +08:00
add logreco
This commit is contained in:
parent
385b6239c8
commit
899d3ff48b
6 changed files with 63 additions and 4 deletions
|
|
@ -13,6 +13,7 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/WJQSERVER-STUDIO/httpc"
|
||||
"github.com/fenthope/reco"
|
||||
)
|
||||
|
||||
// Last 返回链中的最后一个处理函数。
|
||||
|
|
@ -45,6 +46,8 @@ type Engine struct {
|
|||
|
||||
HTTPClient *httpc.Client // 用于在此上下文中执行出站 HTTP 请求。
|
||||
|
||||
LogReco *reco.Logger
|
||||
|
||||
HTMLRender interface{} // 用于 HTML 模板渲染,可以设置为 *template.Template 或自定义渲染器接口
|
||||
|
||||
routesInfo []RouteInfo // 存储所有注册的路由信息
|
||||
|
|
@ -139,6 +142,7 @@ func New() *Engine {
|
|||
}
|
||||
//engine.SetProtocols(GetDefaultProtocolsConfig())
|
||||
engine.SetDefaultProtocols()
|
||||
engine.SetLogger(defaultLogRecoConfig)
|
||||
// 初始化 Context Pool,为每个新 Context 实例提供一个构造函数
|
||||
engine.pool.New = func() interface{} {
|
||||
return &Context{
|
||||
|
|
@ -164,6 +168,11 @@ func Default() *Engine {
|
|||
|
||||
// === 外部操作方法 ===
|
||||
|
||||
// 配置日志Logger
|
||||
func (engine *Engine) SetLogger(logcfg reco.Config) {
|
||||
engine.LogReco = NewLogger(logcfg)
|
||||
}
|
||||
|
||||
// 设置自定义错误处理
|
||||
func (engine *Engine) SetErrorHandler(handler ErrorHandler) {
|
||||
engine.errorHandle.useDefault = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue