{"id":13830267,"url":"https://github.com/dpotapov/slogpfx","last_synced_at":"2026-01-17T02:58:38.119Z","repository":{"id":195295114,"uuid":"692637867","full_name":"dpotapov/slogpfx","owner":"dpotapov","description":"Prefix `slog` messages based on log attributes","archived":false,"fork":false,"pushed_at":"2023-09-17T06:33:53.000Z","size":77,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-04T10:02:48.519Z","etag":null,"topics":["golang","logging","slog"],"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/dpotapov.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}},"created_at":"2023-09-17T05:29:04.000Z","updated_at":"2024-07-23T08:33:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"b85540ca-40fa-45cd-b7a5-58a9a3b1f290","html_url":"https://github.com/dpotapov/slogpfx","commit_stats":null,"previous_names":["dpotapov/slogpfx"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpotapov%2Fslogpfx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpotapov%2Fslogpfx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpotapov%2Fslogpfx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpotapov%2Fslogpfx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dpotapov","download_url":"https://codeload.github.com/dpotapov/slogpfx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225539363,"owners_count":17485313,"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":["golang","logging","slog"],"created_at":"2024-08-04T10:00:58.037Z","updated_at":"2026-01-17T02:58:38.111Z","avatar_url":"https://github.com/dpotapov.png","language":"Go","funding_links":[],"categories":["Formatting"],"sub_categories":[],"readme":"## `slogpfx` - Prefix Logging for `slog`\n\nEasily prefix your log messages with attributes from the log record using `slogpfx`.\n\n![demo](demo.png)\n\n### Features\n\n- Customizable prefix formatter.\n- Colored output by default.\n- Works best with [lmittmann/tint](https://github.com/lmittmann/tint)\n  and [mattn/go-colorable](https://github.com/mattn/go-colorable) packages (some examples below).\n\n### Installation\n\n```bash\ngo get -u github.com/dpotapov/slogpfx\n```\n\n### Usage\n\nHere's a quick example to get you started:\n\n```go\nh := slog.NewTextHandler(os.Stdout, nil)\n\n// Use the prefix based on the attribute \"service\"\nprefixed := slogpfx.NewHandler(h, \u0026slogpfx.HandlerOptions{\n    PrefixKeys:      []string{\"service\"}\n})\n\nlogger := slog.New(prefixed)\n\nlogger.Info(\"Hello World!\")\nlogger.Info(\"Hello World!\", \"service\", \"billing\")\nlogger.With(\"service\", \"database\").Error(\"Connection error\")\n```\n\nUsing in conjunction with [lmittmann/tint](https://github.com/lmittmann/tint)\nand [mattn/go-colorable](https://github.com/mattn/go-colorable) packages:\n\n```go\nh := tint.NewHandler(colorable.NewColorable(os.Stdout), nil)\n\n// Use the prefix based on the attribute \"service\"\nprefixed := slogpfx.NewHandler(h, \u0026slogpfx.HandlerOptions{\n    PrefixKeys:      []string{\"service\"},\n})\n\nlogger := slog.New(prefixed)\n```\n\n### Customization\n\nYou can customize the way prefixes are displayed using the `PrefixFormatter` option.\n\n---\n\nHappy Logging! 📜🖋️\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdpotapov%2Fslogpfx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdpotapov%2Fslogpfx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdpotapov%2Fslogpfx/lists"}