Adding "hooks" for logging/tracing/...
- Ngôn ngữ chính
- Go
- Star
- 39
- Fork
- 47
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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?
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Đọc issue được liên kết về việc logging và các chữ ký được đề xuất của PreRequestHook và PostRequestHook. Kiểm tra newRequest và các hàm client được sinh ra để hiểu các hook và context tùy chọn sẽ được áp dụng ở đâu. Công việc được xem là hoàn tất khi dự án có một thiết kế đã được thống nhất cho các hook của request và việc truyền context, thay vì chỉ có một đề xuất chung.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- go
- Lĩnh vực
- api
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 20/100