Go Wiki:slog 資源
此頁面連結到使用或增強標準函式庫的結構化記錄套件 slog
的專案。
記錄格式化
- slog-formatter:slog 的常見格式化器 + 建立您自己的格式化器的輔助程式:https://github.com/samber/slog-formatter
- ConsoleHandler(類似於 Zap 的 ConsoleEncoder):https://gist.github.com/wijayaerick/de3de10c47a79d5310968ba5ff101a19
- logf(attr {key} 內插、豐富的 tty 輸出):https://pkg.go.dev/github.com/AndrewHarrisSPU/logf(使用 lazy Handler 儲存:https://go.dev.org.tw/play/p/psdD7KDF5fp)
- slogd - slog with duration https://github.com/kaihendry/slogd with video https://youtu.be/IsPa11N5pzI
- tinted (colorized) output: https://pkg.go.dev/github.com/lmittmann/tint
- humane: a human-friendly (but still largely structured) slog Handler: https://github.com/telemachus/humane
- slug: a handler that prints colourful logs for humans: https://github.com/dotse/slug
- slogor: A colorful slog handler: https://gitlab.com/greyxor/slogor
- klog: the text format used by Kubernetes. Provides klog output routing when using the main package’s logger and a simpler logger that just writes to stderr. Both slog/logr and go-logr/logr APIs are supported.
- slogjson: Format using the upcoming JSON v2 library, with optional single-line pretty-printing: https://github.com/veqryn/slog-json
Logger bridge
- Zap Handler, a slog handler that uses Zap: https://github.com/chanchal1987/zaphandler
- zapr: starting with v1.3.0, both slog/logr and go-logr/logr APIs are supported by the same logger instance.
Logging Middleware
- slogctx: store attributes or the logger in context, read any custom values from context: https://github.com/veqryn/slog-context
- slog-context/otel: automatically read and add OpenTelemetry TraceID and SpanID to logs, and can set Span error code: github.com/veqryn/slog-context/otel
- slogdedup:屬性金鑰的重複刪除和排序,具有多種政策,適用於 json 記錄。輸出到 Stackdriver、Graylog 和其他地方的便利方法:https://github.com/veqryn/slog-dedup
HTTP 伺服器中介軟體
- slog-gin:slog 記錄器的 Gin 中介軟體:https://github.com/samber/slog-gin
- slog-echo:slog 記錄器的 Echo 中介軟體:https://github.com/samber/slog-echo
- slog-fiber:slog 記錄器的 Fiber 中介軟體:https://github.com/samber/slog-fiber
- slog-chi:slog 記錄器的 Chi 中介軟體:https://github.com/samber/slog-chi
記錄接收器
- 使用 OpenTelemetry 和
slog
的實驗範例:https://github.com/justinsb/experiments-slog - 具有 opentelemetry 追蹤功能的簡單 slog 處理程式: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
處理器
- slog-multi:
slog.Handler
鏈(管線、扇出,…):https://github.com/samber/slog-multi - 各種處理器: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 日誌: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 的一部分。