{"id":21275868,"url":"https://github.com/pfmt/plog","last_synced_at":"2026-01-12T06:06:47.879Z","repository":{"id":57565687,"uuid":"304439351","full_name":"pfmt/plog","owner":"pfmt","description":"JSON logger for Go.","archived":false,"fork":false,"pushed_at":"2022-07-17T12:01:49.000Z","size":226,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T13:14:10.024Z","etag":null,"topics":["go","golang","log","logging"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pfmt.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}},"created_at":"2020-10-15T20:21:43.000Z","updated_at":"2022-07-17T12:01:22.000Z","dependencies_parsed_at":"2022-08-27T19:01:20.138Z","dependency_job_id":null,"html_url":"https://github.com/pfmt/plog","commit_stats":null,"previous_names":["kvlog/log0","danil/mujlog","danil/logastic","danil/log64","danil/log30","danil/log16","danil/log0","gorelib/plog","pprint/plog"],"tags_count":35,"template":false,"template_full_name":null,"purl":"pkg:github/pfmt/plog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfmt%2Fplog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfmt%2Fplog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfmt%2Fplog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfmt%2Fplog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pfmt","download_url":"https://codeload.github.com/pfmt/plog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfmt%2Fplog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279164009,"owners_count":26117585,"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","status":"online","status_checked_at":"2025-10-16T02:00:06.019Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["go","golang","log","logging"],"created_at":"2024-11-21T09:39:22.306Z","updated_at":"2025-10-16T06:56:59.155Z","avatar_url":"https://github.com/pfmt.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# plog\n\n[![Build Status](https://cloud.drone.io/api/badges/pfmt/plog/status.svg)](https://cloud.drone.io/pfmt/plog)\n[![Go Reference](https://pkg.go.dev/badge/github.com/pfmt/plog.svg)](https://pkg.go.dev/github.com/pfmt/plog)\n\nJSON logger for Go.  \nSource files are distributed under the BSD-style license.\n\n## About\n\nThe software is considered to be at a alpha level of readiness,\nits extremely slow and allocates a lots of memory.\n\n## Usage\n\nSet plog as global logger\n\n```go\npackage main\n\nimport (\n    \"os\"\n    \"log\"\n\n    \"github.com/pfmt/plog\"\n)\n\nfunc main() {\n    l := \u0026plog.Log{\n        Output:  os.Stdout,\n        Keys:    [4]encoding.TextMarshaler{pfmt.String(\"message\"), pfmt.String(\"excerpt\")},\n        Trunc:   12,\n        Marks:   [3][]byte{[]byte(\"…\")},\n        Replace: [][2][]byte{[2][]byte{[]byte(\"\\n\"), []byte(\" \")}},\n    }\n    log.SetFlags(0)\n    log.SetOutput(l)\n\n    log.Print(\"Hello,\\nWorld!\")\n}\n```\n\nOutput:\n\n```json\n{\n    \"message\":\"Hello,\\nWorld!\",\n    \"excerpt\":\"Hello, World…\"\n}\n```\n\n## Use as GELF formater\n\n```go\npackage main\n\nimport (\n    \"log\"\n    \"os\"\n\n    \"github.com/pfmt/plog\"\n)\n\nfunc main() {\n    l := plog.GELF()\n    l.Output = os.Stdout\n    log.SetFlags(0)\n    log.SetOutput(l)\n    log.Print(\"Hello,\\nGELF!\")\n}\n```\n\nOutput:\n\n```json\n{\n    \"version\":\"1.1\",\n    \"short_message\":\"Hello, GELF!\",\n    \"full_message\":\"Hello,\\nGELF!\",\n    \"timestamp\":1602785340\n}\n```\n\n## Caveat: numeric types appears in the message as a string\n\n```go\npackage main\n\nimport (\n    \"log\"\n    \"os\"\n\n    \"github.com/pfmt/plog\"\n)\n\nfunc main() {\n    l := plog.Log{\n        Output: os.Stdout,\n        Keys:   [4]encoding.TextMarshaler{pfmt.String(\"message\")},\n    }\n    log.SetFlags(0)\n    log.SetOutput(l)\n\n    log.Print(123)\n    log.Print(3.21)\n}\n```\n\nOutput 1:\n\n```json\n{\n    \"message\":\"123\"\n}\n```\n\nOutput 2:\n\n```json\n{\n    \"message\":\"3.21\"\n}\n```\n\n## Benchmark\n\n```sh\n$ go test -count=1 -race -bench ./... \ngoos: linux\ngoarch: amd64\npkg: github.com/pfmt/plog\ncpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz\nBenchmarkPlog/plog_test.go:90/io.Writer-8         \t   40026\t     27957 ns/op\nBenchmarkPlog/plog_test.go:1138/fmt.Fprint_io.Writer-8         \t   15207\t     75703 ns/op\nPASS\nok  \tgithub.com/pfmt/plog\t3.506s\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfmt%2Fplog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpfmt%2Fplog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfmt%2Fplog/lists"}