Repository: go-slog/awesome-slog Branch: main Commit: 120a374afcbb Files: 12 Total size: 23.7 KB Directory structure: gitextract_tagiyl9q/ ├── .editorconfig ├── .envrc ├── .github/ │ ├── .editorconfig │ ├── dependabot.yaml │ └── workflows/ │ └── generate.yaml ├── .gitignore ├── CONTRIBUTING.md ├── Makefile ├── README.md ├── README.tmpl.md ├── data.yaml └── flake.nix ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ root = true [*] charset = utf-8 end_of_line = lf indent_size = 4 indent_style = space insert_final_newline = true trim_trailing_whitespace = true [*.nix] indent_size = 2 [{Makefile,*.mk}] indent_style = tab [{*.yaml,*.yml}] indent_size = 2 ================================================ FILE: .envrc ================================================ if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=" fi use flake . --impure ================================================ FILE: .github/.editorconfig ================================================ [{*.yaml,*.yml}] indent_size = 2 ================================================ FILE: .github/dependabot.yaml ================================================ version: 2 updates: - package-ecosystem: github-actions directory: / schedule: interval: daily ================================================ FILE: .github/workflows/generate.yaml ================================================ name: Generate on: push: branches: [main] pull_request: workflow_dispatch: permissions: contents: read jobs: readme: name: README.md runs-on: ubuntu-latest permissions: contents: write steps: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Nix uses: cachix/install-nix-action@3715ab1a11cac9e991980d7b4a28d80c7ebdd8f9 # v27 with: extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - name: Set up magic Nix cache uses: DeterminateSystems/magic-nix-cache-action@87b14cf437d03d37989d87f0fa5ce4f5dc1a330b # v8 - name: Prepare Nix shell run: nix develop --impure .#ci - name: Regenerate README run: nix develop --impure .#ci -c make generate - name: Commit changes uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: Regenerate README.md file_pattern: README.md if: github.event_name == 'push' ================================================ FILE: .gitignore ================================================ /.devenv/ /.direnv/ /bin/ ================================================ FILE: CONTRIBUTING.md ================================================ # Contributing Thank you for contributing to this project! ❤️ Please take a few minutes to read this guide before opening a pull request. The purpose of this project is to help people find resources related to the recently (as of the time of this writing) added `log/slog` package to the standard library. If you find something useful or create a resource yourself, feel free to add it to this list. ## Development **For an optimal developer experience, it is recommended to install [Nix](https://nixos.org/download.html) and [direnv](https://direnv.net/docs/installation.html).** If you do not wish to install Nix, you can install the dependencies by running: ```shell make deps ``` ## Adding a new resource to the list If your intended resource clearly fits into an existing category, feel free to open a pull request. If there is no clear match, please open an issue first to discuss where it should be added (or whether a new category should be created). Add the following details to the `data.yaml` file: - Name (this is generally the name of the package/repository) - Link to the resource - Description Please make sure to maintain an alphabetical order. Once you have added your resource, regenerate the `README.md` file: ```shell make generate ``` > [!TIP] > `README.md` is automatically generated from `data.yaml`. > You can skip running `make generate` locally if you do not have the required dependencies installed. Open a pull request on GitHub. ## What constitutes a "resource"? Anything that may be useful for people trying to use `log/slog`. Generally, these are libraries, but there are blog posts and other types of resources that may be useful. If you are unsure if something has a place here or not, feel free to open an issue to discuss. ================================================ FILE: Makefile ================================================ # A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html export PATH := $(abspath bin/):${PATH} GOMPLATE_VERSION := 3.11.5 .PHONY: generate generate: ## Generate README.md gomplate --datasource contents=./data.yaml --file README.tmpl.md > README.md .PHONY: deps deps: bin/gomplate deps: ## Install dependencies bin/gomplate: @mkdir -p bin/ curl -fsSLo bin/gomplate https://github.com/hairyhenderson/gomplate/releases/download/v$(GOMPLATE_VERSION)/gomplate_$(shell uname -s | tr '[:upper:]' '[:lower:]')-$(shell uname -m) @chmod +x bin/gomplate .PHONY: list list: ## List all make targets @$(MAKE) -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sort .PHONY: help .DEFAULT_GOAL := help help: @grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' ================================================ FILE: README.md ================================================ # Awesome slog **Collection of [log/slog](https://pkg.go.dev/log/slog) related projects.** _Do you have something to add? Please read the [contributing guide](CONTRIBUTING.md) and open a pull request._ ## Contents - [General](#general) - [Formatting](#formatting) - [Enrichment](#enrichment) - [Log forwarding](#log-forwarding) - [Adapters](#adapters) - [Integrations](#integrations) - [Testing](#testing) - [Resources](#resources) - [Blog posts](#blog-posts) - [Creating slog](#creating-slog) ## General _General purpose handlers and integrations._ - [dynamic-level-handler](https://github.com/gekatateam/dynamic-level-handler): Wrapper for `slog.Handler` that supports level override for concrete logger. - [slog-handler-override](https://github.com/martin-viggiano/slog-level-override): A `slog.Handler` wrapper that allows runtime override of any handler's log level. - [slog-exp](https://github.com/smallnest/slog-exp): Individual log files for levels, Wrapping ReplaceAttr, displaying goroutine id, etc. - [slog-multi](https://github.com/samber/slog-multi): Chaining handlers (pipe, router, fanout, etc). - [slog-sampling](https://github.com/samber/slog-sampling): Drop repetitive log entries. - [slog-shim](https://github.com/sagikazarmark/slog-shim): Backward compatible slog support for Go <1.21. - [slogbuffer](https://github.com/delicb/slogbuffer): Buffer log records until real handler is defined. - [slogscope](https://github.com/apperia-de/slogscope): Package based log levels for more fine grained control over logging behavior in large project. - [sloggen](https://github.com/go-simpler/sloggen): Generate various helpers. - [sloglint](https://github.com/go-simpler/sloglint): Ensure consistent code style. **[⬆ back to top](#contents)** ## Formatting _Record and output formatters._ - [console-slog](https://github.com/phsym/console-slog): Handler that prints colorized logs, similar to zerolog's console writer output without sacrificing performances. - [devslog](https://github.com/golang-cz/devslog): Format logs for development. - [golog](https://github.com/primalskill/golog): Development, discard and production handlers with sensible formatting. - [slog-formatter](https://github.com/samber/slog-formatter): Common formatters for slog + helpers for building your own. - [slogcolor](https://github.com/MatusOllah/slogcolor): Color handler for log/slog. - [slogor](https://gitlab.com/greyxor/slogor): A colorful slog handler. - [slogpfx](https://github.com/dpotapov/slogpfx): Easily prefix your log messages with attributes from the log record. - [tint](https://github.com/lmittmann/tint): Handler that writes tinted logs. - [zlog](https://github.com/jeffry-luqman/zlog): Handler that writes beautiful, human readable logs. - [zlog](https://github.com/icefed/zlog): Human-friendly output like zap development, json structured logging with more features for slog. **[⬆ back to top](#contents)** ## Enrichment _Handlers enriching log records._ - [masq](https://github.com/m-mizutani/masq): Redact sensitive data in logs. - [otelslog](https://github.com/go-slog/otelslog): Handler attaching OpenTelemetry trace and resource details to logs. - [slog-aws-lambda](https://github.com/jbleduigou/slog-aws-lambda): Handler for AWS Lambda Functions. - [slog-context](https://github.com/PumpkinSeed/slog-context): Attach arbitrary key-value pairs to log records through context. - [slog-otel](https://github.com/remychantenay/slog-otel): Correlation between slog log records and Open-Telemetry traces. **[⬆ back to top](#contents)** ## Log forwarding _Handlers forwarding logs._ - [slog-clickhouse](https://github.com/smallnest/slog-clickhouse): Handler forwarding logs to ClickHouse. - [slog-datadog](https://github.com/samber/slog-datadog): Handler forwarding logs to Datadog. - [slogdriver](https://github.com/jussi-kalliokoski/slogdriver): Handler forwarding logs to Stackdriver / GCP Cloud Logging. - [slog-fluentd](https://github.com/samber/slog-fluentd): Handler forwarding logs to FluentD. - [slog-graylog](https://github.com/samber/slog-graylog): Handler forwarding logs to Graylog. - [slog-kafka](https://github.com/samber/slog-kafka): Handler forwarding logs to Kafka. - [slog-logstash](https://github.com/samber/slog-logstash): Handler forwarding logs to Logstash. - [slog-loki](https://github.com/samber/slog-loki): Handler forwarding logs to Loki. - [slog-mattermost](https://github.com/samber/slog-mattermost): Handler forwarding logs to Mattermost. - [slog-microsoft-teams](https://github.com/samber/slog-microsoft-teams): Handler forwarding logs to Microsoft Teams. - [slog-parquet](https://github.com/samber/slog-parquet): Handler forwarding logs to an object store in parquet format. - [slog-pushover](https://github.com/SkYNewZ/slog-pushover): Handler forwarding logs to Pushover. - [slog-rollbar](https://github.com/samber/slog-rollbar): Handler forwarding logs to Rollbar. - [slog-sentry](https://github.com/samber/slog-sentry): Handler forwarding logs to Sentry. - [slog-slack](https://github.com/samber/slog-slack): Handler forwarding logs to Slack. - [slog-syslog](https://github.com/samber/slog-syslog): Handler forwarding logs to Syslog. - [slog-telegram](https://github.com/samber/slog-telegram): Handler forwarding logs to Telegram. - [slog-webhook](https://github.com/samber/slog-webhook): Handler forwarding logs to a Webhook. **[⬆ back to top](#contents)** ## Adapters _Adapters for other logging libraries._ - [go-hclog-slog](https://github.com/evanphx/go-hclog-slog): Handler adapter for hclog. - [gslog](https://github.com/maguro/gslog): Handler adapter for Google Cloud Logging. - [slogan](https://github.com/openclosed-dev/slogan): Handler adapter for Azure Application Insights. - [slog-gokit](https://github.com/tjhop/slog-gokit): Go slog handler adapter for go-kit/log. - [slog-logrus](https://github.com/samber/slog-logrus): Handler adapter for logrus. - [slog-zap](https://github.com/samber/slog-zap): Handler adapter for zap. - [slog-zerolog](https://github.com/samber/slog-zerolog): Handler adapter for zerolog. - [zaphandler](https://github.com/chanchal1987/zaphandler): Handler adapter for Zap. **[⬆ back to top](#contents)** ## Integrations _`log/slog` integrations into third-party components._ - [ginslog](https://github.com/FabienMht/ginslog): A fully featured Gin middleware. - [shclog](https://github.com/ValerySidorin/shclog): Hclog adapter for slog. - [slog-chi](https://github.com/samber/slog-chi): Chi middleware. - [slog-echo](https://github.com/samber/slog-echo): Echo middleware. - [slog-fiber](https://github.com/samber/slog-fiber): Fiber middleware. - [slog-gin](https://github.com/samber/slog-gin): Gin middleware. **[⬆ back to top](#contents)** ## Testing _Testing utilities for `log/slog`._ - [slogassert](https://github.com/thejerf/slogassert): slog handler for testing slog code logs expected results. - [slogt](https://github.com/neilotoole/slogt): Bridge between Go `testing.T` and `log/slog`. **[⬆ back to top](#contents)** ## Resources _Other resources about `log/slog`._ - [Reference documentation](https://pkg.go.dev/log/slog) - [Introductory blog post](https://go.dev/blog/slog) - [Golang Wiki page](https://go.dev/wiki/Resources-for-slog) **[⬆ back to top](#contents)** ### Blog posts _Blog posts about `log/slog`._ **[⬆ back to top](#contents)** ### Creating slog _Resources documenting the creation of `log/slog`._ - [Original design proposal](https://go.googlesource.com/proposal/+/master/design/56345-structured-logging.md) - [Initial discussion](https://github.com/golang/go/discussions/54763) - [Proposal issue](https://github.com/golang/go/issues/56345) **[⬆ back to top](#contents)** ================================================ FILE: README.tmpl.md ================================================ # Awesome slog **Collection of [log/slog](https://pkg.go.dev/log/slog) related projects.** _Do you have something to add? Please read the [contributing guide](CONTRIBUTING.md) and open a pull request._ ## Contents {{ range (datasource "contents").categories -}} - [{{ .name }}](#{{ .name | strings.Slug }}) {{- if coll.Has . "categories" }} {{- with .categories }} {{- range . }} - [{{ .name }}](#{{ .name | strings.Slug }}) {{- end }} {{- end }} {{- end }} {{ end -}} {{ range (datasource "contents").categories }} ## {{ .name }} _{{ .description }}_ {{ range .items -}} - [{{ .name }}]({{ .link }}){{ with .description }}: {{ . }}{{ end }} {{ end }} **[⬆ back to top](#contents)** {{- if coll.Has . "categories" }} {{- with .categories }} {{ range . }} ### {{ .name }} _{{ .description }}_ {{ range .items -}} - [{{ .name }}]({{ .link }}){{ with .description }}: {{ . }}{{ end }} {{ end }} **[⬆ back to top](#contents)** {{ end }} {{- end }} {{- end }} {{ end -}} ================================================ FILE: data.yaml ================================================ categories: - name: General description: General purpose handlers and integrations. items: - name: dynamic-level-handler link: https://github.com/gekatateam/dynamic-level-handler description: Wrapper for `slog.Handler` that supports level override for concrete logger. - name: slog-handler-override link: https://github.com/martin-viggiano/slog-level-override description: A `slog.Handler` wrapper that allows runtime override of any handler's log level. - name: slog-exp link: https://github.com/smallnest/slog-exp description: Individual log files for levels, Wrapping ReplaceAttr, displaying goroutine id, etc. - name: slog-multi link: https://github.com/samber/slog-multi description: Chaining handlers (pipe, router, fanout, etc). - name: slog-sampling link: https://github.com/samber/slog-sampling description: Drop repetitive log entries. - name: slog-shim link: https://github.com/sagikazarmark/slog-shim description: Backward compatible slog support for Go <1.21. - name: slogbuffer link: https://github.com/delicb/slogbuffer description: Buffer log records until real handler is defined. - name: slogscope link: https://github.com/apperia-de/slogscope description: Package based log levels for more fine grained control over logging behavior in large project. # Potential new category: Extensions? - name: sloggen link: https://github.com/go-simpler/sloggen description: Generate various helpers. - name: sloglint link: https://github.com/go-simpler/sloglint description: Ensure consistent code style. - name: Formatting description: Record and output formatters. items: - name: console-slog link: https://github.com/phsym/console-slog description: Handler that prints colorized logs, similar to zerolog's console writer output without sacrificing performances. - name: devslog link: https://github.com/golang-cz/devslog description: Format logs for development. - name: golog link: https://github.com/primalskill/golog description: Development, discard and production handlers with sensible formatting. - name: slog-formatter link: https://github.com/samber/slog-formatter description: Common formatters for slog + helpers for building your own. - name: slogcolor link: https://github.com/MatusOllah/slogcolor description: Color handler for log/slog. - name: slogor link: https://gitlab.com/greyxor/slogor description: A colorful slog handler. - name: slogpfx link: https://github.com/dpotapov/slogpfx description: Easily prefix your log messages with attributes from the log record. - name: tint link: https://github.com/lmittmann/tint description: Handler that writes tinted logs. - name: zlog link: https://github.com/jeffry-luqman/zlog description: Handler that writes beautiful, human readable logs. - name: zlog link: https://github.com/icefed/zlog description: Human-friendly output like zap development, json structured logging with more features for slog. - name: Enrichment description: Handlers enriching log records. items: - name: masq link: https://github.com/m-mizutani/masq description: Redact sensitive data in logs. - name: otelslog link: https://github.com/go-slog/otelslog description: Handler attaching OpenTelemetry trace and resource details to logs. - name: slog-aws-lambda link: https://github.com/jbleduigou/slog-aws-lambda description: Handler for AWS Lambda Functions. - name: slog-context link: https://github.com/PumpkinSeed/slog-context description: Attach arbitrary key-value pairs to log records through context. - name: slog-otel link: https://github.com/remychantenay/slog-otel description: Correlation between slog log records and Open-Telemetry traces. - name: Log forwarding description: Handlers forwarding logs. items: - name: slog-clickhouse link: https://github.com/smallnest/slog-clickhouse description: Handler forwarding logs to ClickHouse. - name: slog-datadog link: https://github.com/samber/slog-datadog description: Handler forwarding logs to Datadog. - name: slogdriver link: https://github.com/jussi-kalliokoski/slogdriver description: Handler forwarding logs to Stackdriver / GCP Cloud Logging. - name: slog-fluentd link: https://github.com/samber/slog-fluentd description: Handler forwarding logs to FluentD. - name: slog-graylog link: https://github.com/samber/slog-graylog description: Handler forwarding logs to Graylog. - name: slog-kafka link: https://github.com/samber/slog-kafka description: Handler forwarding logs to Kafka. - name: slog-logstash link: https://github.com/samber/slog-logstash description: Handler forwarding logs to Logstash. - name: slog-loki link: https://github.com/samber/slog-loki description: Handler forwarding logs to Loki. - name: slog-mattermost link: https://github.com/samber/slog-mattermost description: Handler forwarding logs to Mattermost. - name: slog-microsoft-teams link: https://github.com/samber/slog-microsoft-teams description: Handler forwarding logs to Microsoft Teams. - name: slog-parquet link: https://github.com/samber/slog-parquet description: Handler forwarding logs to an object store in parquet format. - name: slog-pushover link: https://github.com/SkYNewZ/slog-pushover description: Handler forwarding logs to Pushover. - name: slog-rollbar link: https://github.com/samber/slog-rollbar description: Handler forwarding logs to Rollbar. - name: slog-sentry link: https://github.com/samber/slog-sentry description: Handler forwarding logs to Sentry. - name: slog-slack link: https://github.com/samber/slog-slack description: Handler forwarding logs to Slack. - name: slog-syslog link: https://github.com/samber/slog-syslog description: Handler forwarding logs to Syslog. - name: slog-telegram link: https://github.com/samber/slog-telegram description: Handler forwarding logs to Telegram. - name: slog-webhook link: https://github.com/samber/slog-webhook description: Handler forwarding logs to a Webhook. - name: Adapters description: Adapters for other logging libraries. items: - name: go-hclog-slog link: https://github.com/evanphx/go-hclog-slog description: Handler adapter for hclog. - name: gslog link: https://github.com/maguro/gslog description: Handler adapter for Google Cloud Logging. - name: slogan link: https://github.com/openclosed-dev/slogan description: Handler adapter for Azure Application Insights. - name: slog-gokit link: https://github.com/tjhop/slog-gokit description: Go slog handler adapter for go-kit/log. - name: slog-logrus link: https://github.com/samber/slog-logrus description: Handler adapter for logrus. - name: slog-zap link: https://github.com/samber/slog-zap description: Handler adapter for zap. - name: slog-zerolog link: https://github.com/samber/slog-zerolog description: Handler adapter for zerolog. - name: zaphandler link: https://github.com/chanchal1987/zaphandler description: Handler adapter for Zap. - name: Integrations description: "`log/slog` integrations into third-party components." items: - name: ginslog link: https://github.com/FabienMht/ginslog description: A fully featured Gin middleware. - name: shclog link: https://github.com/ValerySidorin/shclog description: Hclog adapter for slog. - name: slog-chi link: https://github.com/samber/slog-chi description: Chi middleware. - name: slog-echo link: https://github.com/samber/slog-echo description: Echo middleware. - name: slog-fiber link: https://github.com/samber/slog-fiber description: Fiber middleware. - name: slog-gin link: https://github.com/samber/slog-gin description: Gin middleware. - name: Testing description: Testing utilities for `log/slog`. items: - name: slogassert link: https://github.com/thejerf/slogassert description: slog handler for testing slog code logs expected results. - name: slogt link: https://github.com/neilotoole/slogt description: Bridge between Go `testing.T` and `log/slog`. - name: Resources description: "Other resources about `log/slog`." items: - name: Reference documentation link: https://pkg.go.dev/log/slog description: - name: Introductory blog post link: https://go.dev/blog/slog description: - name: Golang Wiki page link: https://go.dev/wiki/Resources-for-slog description: categories: - name: Blog posts description: "Blog posts about `log/slog`." items: [] - name: Creating slog description: "Resources documenting the creation of `log/slog`." items: - name: Original design proposal link: https://go.googlesource.com/proposal/+/master/design/56345-structured-logging.md description: - name: Initial discussion link: https://github.com/golang/go/discussions/54763 description: - name: Proposal issue link: https://github.com/golang/go/issues/56345 description: ================================================ FILE: flake.nix ================================================ { inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; devenv.url = "github:cachix/devenv"; }; outputs = inputs@{ flake-parts, ... }: flake-parts.lib.mkFlake { inherit inputs; } { imports = [ inputs.devenv.flakeModule ]; systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; perSystem = { config, self', inputs', pkgs, system, ... }: rec { devenv.shells = { default = { packages = with pkgs; [ gomplate ] ++ [ ]; # https://github.com/cachix/devenv/issues/528#issuecomment-1556108767 containers = pkgs.lib.mkForce { }; }; ci = devenv.shells.default; }; }; }; }