{"id":22347655,"url":"https://github.com/pgx-contrib/pgxslog","last_synced_at":"2026-05-15T12:33:27.941Z","repository":{"id":225608529,"uuid":"766379748","full_name":"pgx-contrib/pgxslog","owner":"pgx-contrib","description":"Structured log/slog adapter for pgx v5 — logs queries, batches, and connections with snake_case keys, SQL name extraction, and per-request logger injection","archived":false,"fork":false,"pushed_at":"2026-05-10T12:32:46.000Z","size":57,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-10T14:28:44.554Z","etag":null,"topics":["database","golang","logging","observability","pgx","pgxpool","postgresql","slog","structured-logging","tracelog"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/pgx-contrib/pgxslog","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/pgx-contrib.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-03T05:06:48.000Z","updated_at":"2026-05-10T12:32:48.000Z","dependencies_parsed_at":"2024-08-24T11:52:20.777Z","dependency_job_id":"fb0045fa-fbff-413c-b1c6-a8158ba0f4e1","html_url":"https://github.com/pgx-contrib/pgxslog","commit_stats":null,"previous_names":["pgx-contrib/pgxslog"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pgx-contrib/pgxslog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgx-contrib%2Fpgxslog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgx-contrib%2Fpgxslog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgx-contrib%2Fpgxslog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgx-contrib%2Fpgxslog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgx-contrib","download_url":"https://codeload.github.com/pgx-contrib/pgxslog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgx-contrib%2Fpgxslog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33067307,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["database","golang","logging","observability","pgx","pgxpool","postgresql","slog","structured-logging","tracelog"],"created_at":"2024-12-04T10:10:11.919Z","updated_at":"2026-05-15T12:33:27.936Z","avatar_url":"https://github.com/pgx-contrib.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pgxslog\n\n[![CI](https://github.com/pgx-contrib/pgxslog/actions/workflows/ci.yml/badge.svg)](https://github.com/pgx-contrib/pgxslog/actions/workflows/ci.yml)\n[![Release](https://img.shields.io/github/v/release/pgx-contrib/pgxslog?include_prereleases)](https://github.com/pgx-contrib/pgxslog/releases)\n[![Go Reference](https://pkg.go.dev/badge/github.com/pgx-contrib/pgxslog.svg)](https://pkg.go.dev/github.com/pgx-contrib/pgxslog)\n[![License](https://img.shields.io/github/license/pgx-contrib/pgxslog)](LICENSE)\n[![Go](https://img.shields.io/badge/Go-1.25-00ADD8?logo=go\u0026logoColor=white)](https://go.dev)\n[![pgx](https://img.shields.io/badge/pgx-v5-blue)](https://github.com/jackc/pgx)\n\n`Logger` is a [`log/slog`](https://pkg.go.dev/log/slog) adapter for [pgx v5](https://github.com/jackc/pgx)\nthat routes every database event through the standard structured logging pipeline.\nAssign it to `tracelog.TraceLog` and queries, batches, prepared statements, and\nconnections are logged with snake_case keys, automatic SQL name extraction, and\noptional per-request logger injection via context.\n\n## Installation\n\n```bash\ngo get github.com/pgx-contrib/pgxslog\n```\n\n## Usage\n\n### Connection pool\n\n```go\nconfig, err := pgxpool.ParseConfig(os.Getenv(\"PGX_DATABASE_URL\"))\nif err != nil {\n    panic(err)\n}\n\nconfig.ConnConfig.Tracer = \u0026tracelog.TraceLog{\n    Logger:   \u0026pgxslog.Logger{},\n    LogLevel: tracelog.LogLevelTrace,\n}\n\npool, err := pgxpool.NewWithConfig(context.Background(), config)\nif err != nil {\n    panic(err)\n}\ndefer pool.Close()\n```\n\n### Per-request logger via context\n\nStore a `*slog.Logger` in the context (e.g. one already enriched with a\nrequest ID) and `pgxslog.Logger` will use it instead of `slog.Default()`:\n\n```go\nlogger := slog.New(slog.NewJSONHandler(os.Stdout, nil)).With(\"request_id\", \"abc123\")\nctx := context.WithValue(ctx, pgxslog.LoggerKey, logger)\n\nconfig.ConnConfig.Tracer = \u0026tracelog.TraceLog{\n    Logger:   \u0026pgxslog.Logger{ContextKey: pgxslog.LoggerKey},\n    LogLevel: tracelog.LogLevelInfo,\n}\n```\n\n## Development\n\n### DevContainer\n\nOpen in VS Code with the Dev Containers extension. The environment provides Go,\nPostgreSQL 18, and Nix automatically.\n\n```\nPGX_DATABASE_URL=postgres://vscode@postgres:5432/pgxslog?sslmode=disable\n```\n\n### Nix\n\n```bash\nnix develop          # enter shell with Go\ngo tool ginkgo run -r\n```\n\n### Run tests\n\n```bash\n# Unit tests only (no database required)\ngo tool ginkgo run -r\n\n# With integration tests\nexport PGX_DATABASE_URL=\"postgres://localhost/pgxslog?sslmode=disable\"\ngo tool ginkgo run -r\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgx-contrib%2Fpgxslog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgx-contrib%2Fpgxslog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgx-contrib%2Fpgxslog/lists"}