{"id":34199777,"url":"https://github.com/orian/sdhook","last_synced_at":"2026-03-12T17:27:13.812Z","repository":{"id":57499295,"uuid":"211806240","full_name":"orian/sdhook","owner":"orian","description":"Google Stackdriver logging hook for logrus with recommended API","archived":false,"fork":false,"pushed_at":"2023-02-25T04:43:05.000Z","size":81,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-13T02:36:50.089Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/orian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2019-09-30T07:55:12.000Z","updated_at":"2020-01-10T08:18:36.000Z","dependencies_parsed_at":"2024-06-20T14:08:36.845Z","dependency_job_id":"c712821f-7c07-4d98-bfc4-e673ce3c7ebe","html_url":"https://github.com/orian/sdhook","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/orian/sdhook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orian%2Fsdhook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orian%2Fsdhook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orian%2Fsdhook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orian%2Fsdhook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orian","download_url":"https://codeload.github.com/orian/sdhook/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orian%2Fsdhook/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30434926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T14:34:45.044Z","status":"ssl_error","status_checked_at":"2026-03-12T14:09:33.793Z","response_time":114,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2025-12-15T18:04:24.832Z","updated_at":"2026-03-12T17:27:13.806Z","avatar_url":"https://github.com/orian.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About sdhook\n\nPackage sdhook provides a [logrus](https://github.com/sirupsen/logrus)\ncompatible hook for [Google Stackdriver logging](https://cloud.google.com/logging/).\n\nThis is a hard fork of [github.com/knq/sdhook](https://github.com/knq/sdhook).\nIt adds semantic versioning and replaces deprecated\n[google.golang.org/api/logging/v2](https://google.golang.org/api/logging/v2)\nwith [cloud.google.com/go/logging](https://cloud.google.com/go/logging)\n\n# Installation\n\nInstall in the usual Go way:\n```sh\ngo get -u github.com/orian/sdhook\n```\n\n# Usage\n\nSimply create the hook, and add it to a logrus logger:\n\n```go\n// create hook using service account credentials\nh, err := sdhook.New(\n\tsdhook.GoogleServiceAccountCredentialsFile(\"./credentials.json\"),\n)\n\n// create logger with extra fields\n//\n// logrus fields will be converted to Stackdriver labels\nlogger := logrus.New().WithFields(logrus.Fields{\n\t\"field1\": 15,\n\t\"field2\": 20,\n})\n\n// add hook\nlogger.Hooks.Add(h)\n\n// log something\nlogger.Printf(\"something %d\", 15)\n```\n\nThe example above sends log entries directly to the logging API. If you have the logging agent running, you can send log entries to it instead, with the added benefit of having extra instance metadata added to your log entries by the agent. In the example above, the initialization would simply be:\n\n```go\n// create hook using the logging agent\nh, err := sdhook.New(\n\tsdhook.GoogleLoggingAgent(),\n)\n```\n\nPlease also see [example/example.go](example/example.go) for a more complete\nexample.\n\n## Error Reporting\n\nIf you'd like to enable sending errors to Google's Error Reporting (https://cloud.google.com/error-reporting/), you have to set the name of the service, app or system you're running. Following the example above, the initialization would then be:\n\n```go\n// create hook using the logging agent\nh, err := sdhook.New(\n\tsdhook.GoogleLoggingAgent(),\n\tsdhook.ErrorReportingService(\"your-great-app\"),\n)\n```\n\nThe value of the `ErrorReportingService` function parameter above corresponds to the string value you'd like to see in the `service` field of the Error Reporting payload, as defined by https://cloud.google.com/error-reporting/docs/formatting-error-messages\n\nAlso note that, if you enable error reporting, errors and messages of more severe levels go into the error log and will not be displayed in the regular log. The error log name is either defined by the `ErrorReportingLogName` function or defaults to `\u003cregular-log-name\u003e_errors`. This fulfills Google's Error Reporting requirement that the log name should have the string `err` in its name. See more in: https://cloud.google.com/error-reporting/docs/setup/ec2\n\nSee [GoDoc](https://godoc.org/github.com/knq/sdhook) for a full API listing.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forian%2Fsdhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forian%2Fsdhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forian%2Fsdhook/lists"}