{"id":13830384,"url":"https://github.com/samber/slog-webhook","last_synced_at":"2025-09-05T16:16:29.377Z","repository":{"id":159389442,"uuid":"634623566","full_name":"samber/slog-webhook","owner":"samber","description":"🚨 slog: Webhook handler","archived":false,"fork":false,"pushed_at":"2025-09-02T14:29:48.000Z","size":95,"stargazers_count":11,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-02T16:23:47.668Z","etag":null,"topics":["attribute","error","go","golang","handler","http","log","log-level","logger","middleware","slog","structured-logging","webhook"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/samber/slog-webhook/v2","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["samber"]}},"created_at":"2023-04-30T18:16:41.000Z","updated_at":"2025-09-02T14:29:52.000Z","dependencies_parsed_at":"2023-10-25T09:54:01.473Z","dependency_job_id":"cd6d4835-3afe-415c-beb8-6be6facdf57d","html_url":"https://github.com/samber/slog-webhook","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/samber/slog-webhook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samber%2Fslog-webhook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samber%2Fslog-webhook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samber%2Fslog-webhook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samber%2Fslog-webhook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samber","download_url":"https://codeload.github.com/samber/slog-webhook/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samber%2Fslog-webhook/sbom","scorecard":{"id":797163,"data":{"date":"2025-08-11","repo":{"name":"github.com/samber/slog-webhook","commit":"eaa21c24727389e789359a52d3515bb55a0e5e66"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.7,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":3,"reason":"4 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/16 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-webhook/lint.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-webhook/lint.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/lint.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-webhook/lint.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/lint.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-webhook/lint.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-webhook/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-webhook/release.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:56: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-webhook/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-webhook/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-webhook/test.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-webhook/test.yml/main?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   4 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/lint.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 14 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T09:20:09.395Z","repository_id":159389442,"created_at":"2025-08-23T09:20:09.395Z","updated_at":"2025-08-23T09:20:09.395Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273782459,"owners_count":25167134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["attribute","error","go","golang","handler","http","log","log-level","logger","middleware","slog","structured-logging","webhook"],"created_at":"2024-08-04T10:00:59.326Z","updated_at":"2025-09-05T16:16:29.368Z","avatar_url":"https://github.com/samber.png","language":"Go","readme":"\n# slog: Webhook handler\n\n[![tag](https://img.shields.io/github/tag/samber/slog-webhook.svg)](https://github.com/samber/slog-webhook/releases)\n![Go Version](https://img.shields.io/badge/Go-%3E%3D%201.21-%23007d9c)\n[![GoDoc](https://godoc.org/github.com/samber/slog-webhook?status.svg)](https://pkg.go.dev/github.com/samber/slog-webhook)\n![Build Status](https://github.com/samber/slog-webhook/actions/workflows/test.yml/badge.svg)\n[![Go report](https://goreportcard.com/badge/github.com/samber/slog-webhook)](https://goreportcard.com/report/github.com/samber/slog-webhook)\n[![Coverage](https://img.shields.io/codecov/c/github/samber/slog-webhook)](https://codecov.io/gh/samber/slog-webhook)\n[![Contributors](https://img.shields.io/github/contributors/samber/slog-webhook)](https://github.com/samber/slog-webhook/graphs/contributors)\n[![License](https://img.shields.io/github/license/samber/slog-webhook)](./LICENSE)\n\nA [webhook](https://webhook.com) Handler for [slog](https://pkg.go.dev/log/slog) Go library.\n\n\u003cdiv align=\"center\"\u003e\n  \u003chr\u003e\n  \u003csup\u003e\u003cb\u003eSponsored by:\u003c/b\u003e\u003c/sup\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://www.dash0.com\"\u003e\n    \u003cdiv\u003e\n      \u003cimg src=\"https://github.com/user-attachments/assets/b1f2e876-0954-4dc3-824d-935d29ba8f3f\" width=\"200\" alt=\"Dash0\"\u003e\n    \u003c/div\u003e\n    \u003cdiv\u003e\n      100% OpenTelemetry-native observability platform\u003cbr\u003eSimple to use, built on open standards, and designed for full cost control\n    \u003c/div\u003e\n  \u003c/a\u003e\n  \u003chr\u003e\n\u003c/div\u003e\n\n**See also:**\n\n- [slog-multi](https://github.com/samber/slog-multi): `slog.Handler` chaining, fanout, routing, failover, load balancing...\n- [slog-formatter](https://github.com/samber/slog-formatter): `slog` attribute formatting\n- [slog-sampling](https://github.com/samber/slog-sampling): `slog` sampling policy\n- [slog-mock](https://github.com/samber/slog-mock): `slog.Handler` for test purposes\n\n**HTTP middlewares:**\n\n- [slog-gin](https://github.com/samber/slog-gin): Gin middleware for `slog` logger\n- [slog-echo](https://github.com/samber/slog-echo): Echo middleware for `slog` logger\n- [slog-fiber](https://github.com/samber/slog-fiber): Fiber middleware for `slog` logger\n- [slog-chi](https://github.com/samber/slog-chi): Chi middleware for `slog` logger\n- [slog-http](https://github.com/samber/slog-http): `net/http` middleware for `slog` logger\n\n**Loggers:**\n\n- [slog-zap](https://github.com/samber/slog-zap): A `slog` handler for `Zap`\n- [slog-zerolog](https://github.com/samber/slog-zerolog): A `slog` handler for `Zerolog`\n- [slog-logrus](https://github.com/samber/slog-logrus): A `slog` handler for `Logrus`\n\n**Log sinks:**\n\n- [slog-datadog](https://github.com/samber/slog-datadog): A `slog` handler for `Datadog`\n- [slog-betterstack](https://github.com/samber/slog-betterstack): A `slog` handler for `Betterstack`\n- [slog-rollbar](https://github.com/samber/slog-rollbar): A `slog` handler for `Rollbar`\n- [slog-loki](https://github.com/samber/slog-loki): A `slog` handler for `Loki`\n- [slog-sentry](https://github.com/samber/slog-sentry): A `slog` handler for `Sentry`\n- [slog-syslog](https://github.com/samber/slog-syslog): A `slog` handler for `Syslog`\n- [slog-logstash](https://github.com/samber/slog-logstash): A `slog` handler for `Logstash`\n- [slog-fluentd](https://github.com/samber/slog-fluentd): A `slog` handler for `Fluentd`\n- [slog-graylog](https://github.com/samber/slog-graylog): A `slog` handler for `Graylog`\n- [slog-quickwit](https://github.com/samber/slog-quickwit): A `slog` handler for `Quickwit`\n- [slog-slack](https://github.com/samber/slog-slack): A `slog` handler for `Slack`\n- [slog-telegram](https://github.com/samber/slog-telegram): A `slog` handler for `Telegram`\n- [slog-mattermost](https://github.com/samber/slog-mattermost): A `slog` handler for `Mattermost`\n- [slog-microsoft-teams](https://github.com/samber/slog-microsoft-teams): A `slog` handler for `Microsoft Teams`\n- [slog-webhook](https://github.com/samber/slog-webhook): A `slog` handler for `Webhook`\n- [slog-kafka](https://github.com/samber/slog-kafka): A `slog` handler for `Kafka`\n- [slog-nats](https://github.com/samber/slog-nats): A `slog` handler for `NATS`\n- [slog-parquet](https://github.com/samber/slog-parquet): A `slog` handler for `Parquet` + `Object Storage`\n- [slog-channel](https://github.com/samber/slog-channel): A `slog` handler for Go channels\n\n## 🚀 Install\n\n```sh\ngo get github.com/samber/slog-webhook/v2\n```\n\n**Compatibility**: go \u003e= 1.21\n\nNo breaking changes will be made to exported APIs before v3.0.0.\n\n## 💡 Usage\n\nGoDoc: [https://pkg.go.dev/github.com/samber/slog-webhook/v2](https://pkg.go.dev/github.com/samber/slog-webhook/v2)\n\n### Handler options\n\n```go\ntype Option struct {\n  // log level (default: debug)\n  Level     slog.Leveler\n\n  // URL\n  Endpoint string\n  Timeout  time.Duration // default: 10s\n\n  // optional: customize webhook event builder\n  Converter Converter\n  // optional: custom marshaler\n  Marshaler func(v any) ([]byte, error)\n  // optional: fetch attributes from context\n  AttrFromContext []func(ctx context.Context) []slog.Attr\n\n  // optional: see slog.HandlerOptions\n  AddSource   bool\n  ReplaceAttr func(groups []string, a slog.Attr) slog.Attr\n}\n```\n\nOther global parameters:\n\n```go\nslogwebhook.SourceKey = \"source\"\nslogwebhook.ContextKey = \"extra\"\nslogwebhook.ErrorKeys = []string{\"error\", \"err\"}\nslogwebhook.RequestIgnoreHeaders = false\n```\n\n### Supported attributes\n\nThe following attributes are interpreted by `slogwebhook.DefaultConverter`:\n\n| Atribute name    | `slog.Kind`       | Underlying type |\n| ---------------- | ----------------- | --------------- |\n| \"user\"           | group (see below) |                 |\n| \"error\"          | any               | `error`         |\n| \"request\"        | any               | `*http.Request` |\n| other attributes | *                 |                 |\n\nOther attributes will be injected in `extra` field.\n\nUsers must be of type `slog.Group`. Eg:\n\n```go\nslog.Group(\"user\",\n  slog.String(\"id\", \"user-123\"),\n  slog.String(\"username\", \"samber\"),\n  slog.Time(\"created_at\", time.Now()),\n)\n```\n\n### Example\n\n```go\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"time\"\n\n\tslogwebhook \"github.com/samber/slog-webhook/v2\"\n\n\t\"log/slog\"\n)\n\nfunc main() {\n  url := \"https://webhook.site/xxxxxx\"\n\n  logger := slog.New(slogwebhook.Option{Level: slog.LevelDebug, Endpoint: url}.NewWebhookHandler())\n  logger = logger.With(\"release\", \"v1.0.0\")\n\n  req, _ := http.NewRequest(http.MethodGet, \"https://api.screeb.app\", nil)\n  req.Header.Set(\"Content-Type\", \"application/json\")\n  req.Header.Set(\"X-TOKEN\", \"1234567890\")\n\n  logger.\n    With(\n      slog.Group(\"user\",\n        slog.String(\"id\", \"user-123\"),\n        slog.Time(\"created_at\", time.Now()),\n      ),\n    ).\n    With(\"request\", req).\n    With(\"error\", fmt.Errorf(\"an error\")).\n    Error(\"a message\")\n}\n```\n\nOutput:\n\n```json\n{\n  \"error\": {\n    \"error\": \"an error\",\n    \"kind\": \"*errors.errorString\",\n    \"stack\": null\n  },\n  \"extra\": {\n\t\"release\": \"v1.0.0\"\n  },\n  \"level\": \"ERROR\",\n  \"logger\": \"samber/slog-webhook\",\n  \"message\": \"a message\",\n  \"request\": {\n    \"headers\": {\n      \"Content-Type\": \"application/json\",\n      \"X-Token\": \"1234567890\"\n    },\n    \"host\": \"api.screeb.app\",\n    \"method\": \"GET\",\n    \"url\": {\n      \"fragment\": \"\",\n      \"host\": \"api.screeb.app\",\n      \"path\": \"\",\n      \"query\": {},\n      \"raw_query\": \"\",\n      \"scheme\": \"https\",\n      \"url\": \"https://api.screeb.app\"\n    }\n  },\n  \"timestamp\": \"2023-04-10T14:00:0.000000\",\n  \"user\": {\n\t\"id\": \"user-123\",\n    \"created_at\": \"2023-04-10T14:00:0.000000\"\n  }\n}\n```\n\n### Tracing\n\nImport the samber/slog-otel library.\n\n```go\nimport (\n\tslogwebhook \"github.com/samber/slog-webhook\"\n\tslogotel \"github.com/samber/slog-otel\"\n\t\"go.opentelemetry.io/otel/sdk/trace\"\n)\n\nfunc main() {\n\ttp := trace.NewTracerProvider(\n\t\ttrace.WithSampler(trace.AlwaysSample()),\n\t)\n\ttracer := tp.Tracer(\"hello/world\")\n\n\tctx, span := tracer.Start(context.Background(), \"foo\")\n\tdefer span.End()\n\n\tspan.AddEvent(\"bar\")\n\n\tlogger := slog.New(\n\t\tslogwebhook.Option{\n\t\t\t// ...\n\t\t\tAttrFromContext: []func(ctx context.Context) []slog.Attr{\n\t\t\t\tslogotel.ExtractOtelAttrFromContext([]string{\"tracing\"}, \"trace_id\", \"span_id\"),\n\t\t\t},\n\t\t}.NewWebhookHandler(),\n\t)\n\n\tlogger.ErrorContext(ctx, \"a message\")\n}\n```\n\n## 🤝 Contributing\n\n- Ping me on twitter [@samuelberthe](https://twitter.com/samuelberthe) (DMs, mentions, whatever :))\n- Fork the [project](https://github.com/samber/slog-webhook)\n- Fix [open issues](https://github.com/samber/slog-webhook/issues) or request new features\n\nDon't hesitate ;)\n\n```bash\n# Install some dev dependencies\nmake tools\n\n# Run tests\nmake test\n# or\nmake watch-test\n```\n\n## 👤 Contributors\n\n![Contributors](https://contrib.rocks/image?repo=samber/slog-webhook)\n\n## 💫 Show your support\n\nGive a ⭐️ if this project helped you!\n\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/samber?style=for-the-badge)](https://github.com/sponsors/samber)\n\n## 📝 License\n\nCopyright © 2023 [Samuel Berthe](https://github.com/samber).\n\nThis project is [MIT](./LICENSE) licensed.\n","funding_links":["https://github.com/sponsors/samber"],"categories":["Log forwarding"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamber%2Fslog-webhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamber%2Fslog-webhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamber%2Fslog-webhook/lists"}