Go Wiki: slog 資源
此頁面連結到使用或增強標準庫中的結構化日誌包 slog
的專案。
日誌格式化
- slog-formatter: slog 的通用格式化器 + 構建自己的幫助程式: https://github.com/samber/slog-formatter
- ConsoleHandler (類似於 Zap 的 ConsoleEncoder): https://gist.github.com/wijayaerick/de3de10c47a79d5310968ba5ff101a19
- logf (屬性 {key} 插值, 富 tty 輸出): https://pkg.go.dev/github.com/AndrewHarrisSPU/logf (使用惰性 Handler 儲存: https://golang.org.tw/play/p/psdD7KDF5fp )
- slogd - 帶持續時間的 slog https://github.com/kaihendry/slogd 帶影片 https://youtu.be/IsPa11N5pzI
- tinted (彩色) 輸出: https://pkg.go.dev/github.com/lmittmann/tint
- humane: 一個對人類友好 (但仍然很大程度上是結構化的) slog Handler: https://github.com/telemachus/humane
- slug: 一個為人類列印彩色日誌的 handler: https://github.com/dotse/slug
- slogor: 一個彩色的 slog handler: https://gitlab.com/greyxor/slogor
- klog: Kubernetes 使用的文字格式。在使用主包的 logger 和 一個更簡單的 logger 時提供 klog 輸出路由,該 logger 只寫入 stderr。slog/logr 和 go-logr/logr API 都支援。
- slogjson: 使用即將推出的 JSON v2 庫進行格式化,可選單行美化列印: https://github.com/veqryn/slog-json
Logger 橋接
- Zap Handler, 一個使用 Zap 的 slog handler: https://github.com/chanchal1987/zaphandler
- zapr: 從 v1.3.0 開始,同一個 logger 例項同時支援 slog/logr 和 go-logr/logr API。
- GoKit 的 handler: https://github.com/tjhop/slog-gokit。
Logging Middleware (日誌中介軟體)
- slogctx: 在 context 中儲存屬性或 logger, 從 context 中讀取任何自定義值: https://github.com/veqryn/slog-context
- slog-context/otel: 自動讀取並將 OpenTelemetry TraceID 和 SpanID 新增到日誌中,並可以設定 Span 錯誤程式碼: github.com/veqryn/slog-context/otel
- slogdedup: 屬性鍵的去重和排序,具有多種策略,適用於 json 日誌。用於 Stackdriver, Graylog 等的便捷方法: https://github.com/veqryn/slog-dedup
HTTP 伺服器中介軟體
- slog-gin: slog logger 的 Gin 中介軟體: https://github.com/samber/slog-gin
- slog-echo: slog logger 的 Echo 中介軟體: https://github.com/samber/slog-echo
- slog-fiber: slog logger 的 Fiber 中介軟體: https://github.com/samber/slog-fiber
- slog-chi: slog logger 的 Chi 中介軟體: https://github.com/samber/slog-chi
Log sinks (日誌接收器)
- 實驗性示例,同時使用 OpenTelemetry 和
slog
: https://github.com/justinsb/experiments-slog - 具有 opentelemetry 跟蹤的簡單 slog handler: https://github.com/ttys3/slogsimple/tree/main
- slog-datadog: Datadog 的
slog.Handler
: https://github.com/samber/slog-datadog - slog-rollbar: Rollbar 的
slog.Handler
: https://github.com/samber/slog-rollbar - slog-sentry: Sentry 的
slog.Handler
: https://github.com/samber/slog-sentry - slog-syslog: Syslog 的
slog.Handler
: https://github.com/samber/slog-syslog - slog-logstash: Logstash 的
slog.Handler
: https://github.com/samber/slog-logstash - slog-fluentd: Fluentd 的
slog.Handler
: https://github.com/samber/slog-fluentd - slog-graylog: Graylog 的
slog.Handler
: https://github.com/samber/slog-graylog - slog-loki: Loki 的
slog.Handler
: https://github.com/samber/slog-loki - slog-slack: Slack 的
slog.Handler
: https://github.com/samber/slog-slack - slog-telegram: Telegram 的
slog.Handler
: https://github.com/samber/slog-telegram - slog-mattermost: Mattermost 的
slog.Handler
: https://github.com/samber/slog-mattermost - slog-microsoft-teams: Microsoft Teams 的
slog.Handler
: https://github.com/samber/slog-microsoft-teams - slog-webhook: Webhook 的
slog.Handler
: https://github.com/samber/slog-webhook - slog-kafka: Kafka 的
slog.Handler
: https://github.com/samber/slog-kafka - slogbugsnag: Bugsnag 的
slog.Handler
: https://github.com/veqryn/slog-bugsnag - slogdriver: Stackdriver Logging / GCP Cloud Logging 的
slog.Handler
: https://github.com/jussi-kalliokoski/slogdriver
Handlers (Handler)
- slog-multi:
slog.Handler
鏈 (管道, fanout, …): https://github.com/samber/slog-multi - 各種 handlers: https://github.com/galecore/xslog
其他
- jba 撰寫的其他資源: https://github.com/jba/slog
- slog-sampling: 丟棄重複的日誌條目: https://github.com/samber/slog-sampling
- slog-context: 新增從 context 讀取值的功能: https://github.com/PumpkinSeed/slog-context
- slogassert: 用於測試程式碼發出的 slog 日誌的 handle: https://github.com/thejerf/slogassert
- sloggen: 為
log/slog
生成各種輔助工具: https://github.com/go-simpler/sloggen - sloglint: 確保使用
log/slog
時程式碼風格一致: https://github.com/go-simpler/sloglint
此內容是 Go Wiki 的一部分。