Adding "hooks" for logging/tracing/...
- 主要語言
- Go
- 星號
- 39
- 分支
- 47
- PR 合併指標
- 30 天內沒有已合併 PR
描述
This issue is a follow-up of https://github.com/xanzy/go-cloudstack/issues/120.
That issue was opened by @synergiator with the title "How to change the log level for go-cloudstack module?" and asked for a way to have more detailed logging.
I proposed a broader solution:
> I also think that adding logging would be useful, but as there's never consensus on what to log or which logging library to use (log, zap, logrus, etc.), what would you think of adding some "hooks", optional functions that would be called before and after the actual http request? The user of CloudStack client could then provide its own logging or tracing logic.
>
> IMHO, the best would be to also add an **optional** context.Context to all API functions, in order to make it possible to do contextual tracing for example.
>
> A possible signature for these hooks could be:
>
> ```go
> // PreRequestHook would be called in newRequest, just before the HTTP request call.
> type PreRequestHook func(ctx context.Context, api string, params url.Values)
>
> // PostRequestHook would be called in each generated client function,
> // just after the Unmarshal step.
> type PostRequestHook func(ctx context.Context, rawResp json.RawMessage, err error, resp interface{})
> ```
>
> I can contribute and submit a PR if you are ok with that.
Any thoughts?
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
閱讀關於 logging 以及所提議的 PreRequestHook 和 PostRequestHook 簽章的連結 issue。檢查 newRequest 和產生的 client 函式,以了解 hooks 和選用的 context 將在哪裡套用。只有當專案對 request hooks 和 context 傳遞形成一致的設計,而不只是一般性的提案時,才算完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- go
- 領域
- api
- Issue 類型
- 功能
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 20/100