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 使用的文字格式。在使用 main 包的日誌器時提供 klog 輸出路由,並提供一個更簡單的日誌器,只寫入到 stderr。支援 slog/logr 和 go-logr/logr API。
- slogjson:使用即將推出的JSON v2 庫進行格式化,可選單行美化列印: https://github.com/veqryn/slog-json
日誌器橋接
- Zap Handler,一個使用 Zap 的 slog Handler: https://github.com/chanchal1987/zaphandler
- zapr:從 v1.3.0 開始,同一個日誌器例項同時支援 slog/logr 和 go-logr/logr API。
- GoKit 的 Handler: https://github.com/tjhop/slog-gokit。
日誌中介軟體
- slogctx:在上下文(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:Gin 框架的 slog 日誌器中介軟體: https://github.com/samber/slog-gin
- slog-echo:Echo 框架的 slog 日誌器中介軟體: https://github.com/samber/slog-echo
- slog-fiber:Fiber 框架的 slog 日誌器中介軟體: https://github.com/samber/slog-fiber
- slog-chi:Chi 框架的 slog 日誌器中介軟體: https://github.com/samber/slog-chi
日誌接收器
- 使用 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
- slog-multi:
slog.Handler
鏈(管道、扇出等): https://github.com/samber/slog-multi - 各種 handler: https://github.com/galecore/xslog
其他
- jba 編寫的額外資源: https://github.com/jba/slog
- slog-sampling:丟棄重複的日誌條目: https://github.com/samber/slog-sampling
- slog-context:新增從上下文讀取值的支援: https://github.com/PumpkinSeed/slog-context
- slogassert:用於測試程式碼發出的 slog 日誌的 handler: 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 的一部分。