{"id":18303117,"url":"https://github.com/monzo/slog","last_synced_at":"2025-04-05T16:04:20.714Z","repository":{"id":45969112,"uuid":"52161261","full_name":"monzo/slog","owner":"monzo","description":"Structured logging","archived":false,"fork":false,"pushed_at":"2025-01-28T16:15:20.000Z","size":57,"stargazers_count":48,"open_issues_count":0,"forks_count":9,"subscribers_count":81,"default_branch":"master","last_synced_at":"2025-03-29T15:03:05.616Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/monzo.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":"2016-02-20T15:54:50.000Z","updated_at":"2025-03-11T11:18:01.000Z","dependencies_parsed_at":"2024-02-12T16:31:46.382Z","dependency_job_id":"1afa4736-b37a-4439-9165-85683f8f0d70","html_url":"https://github.com/monzo/slog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monzo%2Fslog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monzo%2Fslog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monzo%2Fslog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monzo%2Fslog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monzo","download_url":"https://codeload.github.com/monzo/slog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247361614,"owners_count":20926642,"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","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":"2024-11-05T15:24:15.626Z","updated_at":"2025-04-05T16:04:20.666Z","avatar_url":"https://github.com/monzo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `slog`\n**S**tructured **log**ging.\n\nslog is a library for capturing structured log information. In contrast to \"traditional\" logging libraries, slog:\n\n* captures a [Context](https://golang.org/pkg/context/) for each event\n* captures arbitrary key-value metadata on each log event\n\nslog forwards messages to [`log`](https://golang.org/pkg/log/) by default. But you probably want to write a custom output to make use of the context and metadata. At [Monzo](https://monzo.com/), slog captures events both on a per-service and a per-request basis (using the context information) and sends them to a centralised logging system. This lets us view all the logs for a given request across all the micro-services it touches.\n\n## Usage\n\nInternally at Monzo, we recommend that users always prefer structured logging where possible. An example of using slog for this would be:\n\n```go\nslog.Info(ctx, \"Loading widget\", map[string]interface{}{\n    \"stage\": \"reticulating splines\",\n})\n```\n\n### Errors\n\n`slog` also provides a shorthand for capturing errors in the form of:\n\n```go\nslog.Error(ctx, \"Failed to load widget\", err)\n```\n\nYou may also add metadata to errors captured this way:\n\n```go\nslog.Error(ctx, \"Failed to load widget\", err, map[string]interface{}{\n    \"user_id\": 42,\n})\n```\n\nSlog will pick up the first `error` it finds in the metadata and make it available in `event.Error`.\n\n### Other uses\n\nFor backwards-compatibility, slog accepts metadata in the form of `map[string]string`.\n\nIt also accepts format parameters in the style of `Printf`:\n\n```go\nstage := \"reticulating splines\"\nslog.Info(ctx, \"Loading widget at stage: %s\", stage)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonzo%2Fslog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonzo%2Fslog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonzo%2Fslog/lists"}