{"id":36824488,"url":"https://github.com/scanoss/zap-logging-helper","last_synced_at":"2026-01-12T14:03:22.962Z","repository":{"id":61839688,"uuid":"554127616","full_name":"scanoss/zap-logging-helper","owner":"scanoss","description":"Provide common go zap/grpc helper functions","archived":false,"fork":false,"pushed_at":"2024-09-01T02:44:24.000Z","size":187,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-09-15T18:41:54.704Z","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/scanoss.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2022-10-19T09:44:49.000Z","updated_at":"2024-08-23T12:09:15.000Z","dependencies_parsed_at":"2025-03-31T19:27:30.119Z","dependency_job_id":"a0825c60-4b50-410d-95f0-905cecb9b86a","html_url":"https://github.com/scanoss/zap-logging-helper","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/scanoss/zap-logging-helper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scanoss%2Fzap-logging-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scanoss%2Fzap-logging-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scanoss%2Fzap-logging-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scanoss%2Fzap-logging-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scanoss","download_url":"https://codeload.github.com/scanoss/zap-logging-helper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scanoss%2Fzap-logging-helper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28340242,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":"2026-01-12T14:03:22.849Z","updated_at":"2026-01-12T14:03:22.944Z","avatar_url":"https://github.com/scanoss.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SCANOSS Platform 2.0 Zap Logging Helper Package\nWelcome to the SCANOSS Platform 2.0 zap logging helper package.\n\nThis package contains helper functions to make development of Go gRPC services easier to configure for logging.\n\n[![Golang CI Lint](https://github.com/scanoss/zap-logging-helper/actions/workflows/golangci-lint.yml/badge.svg)](https://github.com/scanoss/zap-logging-helper/actions/workflows/golangci-lint.yml)\n[![Go Unit Test](https://github.com/scanoss/zap-logging-helper/actions/workflows/go-ci.yml/badge.svg)](https://github.com/scanoss/zap-logging-helper/actions/workflows/go-ci.yml)\n\n## Repository Structure\nThis repository is made up of the following components:\n* Zap logging initialisation\n* gRPC interceptor to add request/response IDs to logging\n\n## Usage\n### Zap Logger\nWhen leveraging a zap logger in an application, it can be problematic to instantiate an instance and maintain access to this.\nThe zap `logger` package simplifies this by providing two global variables which give access to both the standard (faster) `Logger` and the more format friendly `Sugared Logger`.\n\nInstantiation of these loggers is further simplified by providing opinionated versions. These include:\n* Simple Dev Logger (`NewDevLogger`)\n* Simple Prod Logger (`NewProdLogger`)\n* Simple Dev/Prod Logger with initial Level (`NewDevLogger(level)`, `NewProdLogger(level)`)\n\nThere is also an advanced version which allowed for the importation of config from a file: `NewLoggerFromFile`\n\nThis package also provides support for dynamic level setting (`AtomicLevel`) while the application is running.\nThis can (optionally) be exposed to HTTP to provide external manipulation of the logging level: `SetupDynamicLogging(addr)`\n\n### gRPC Context Server Interceptor\nWhen working with gRPC services, it's important to provide context to all requests to aid tracing/debugging/etc.\n\nThe `github.com/grpc-ecosystem/go-grpc-middleware` package provides some amazing features to help in this area (more details [here](https://github.com/grpc-ecosystem/go-grpc-middleware)).\nIt provides examples and support for gathering context from a gRPC request, and interceptors to simplify this process.\n\nThe interceptors in this package provide an opinionated implementation of these examples.\nPrincipally, these interceptors are designed to do the following:\n* Check the incoming request headers for the `x-request-id` field. If none is detected, automatically generate one.\n* Add this request id to all subsequent downstream calls\n* Copy the `x-request-id` to the `x-response-id` and add it to the response header\n* Add the `x-request-id` to the zap logging context, so that it is logged with all events generated\n\n## Bugs/Features\nTo request features or alert about bugs, please do so [here](https://github.com/scanoss/zap-logging-helper/issues).\n\n## Changelog\nDetails of major changes to the library can be found in [CHANGELOG.md](CHANGELOG.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscanoss%2Fzap-logging-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscanoss%2Fzap-logging-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscanoss%2Fzap-logging-helper/lists"}