{"id":15457574,"url":"https://github.com/maoueh/zap-pretty","last_synced_at":"2025-04-09T11:11:51.977Z","repository":{"id":52566781,"uuid":"161216785","full_name":"maoueh/zap-pretty","owner":"maoueh","description":"A tiny binary to pretty-print Zap production JSON lines","archived":false,"fork":false,"pushed_at":"2025-03-06T02:11:44.000Z","size":198,"stargazers_count":57,"open_issues_count":5,"forks_count":14,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T09:08:01.015Z","etag":null,"topics":["cli","pretty","zap"],"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/maoueh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2018-12-10T18:10:27.000Z","updated_at":"2025-03-14T19:57:15.000Z","dependencies_parsed_at":"2024-06-19T00:02:31.908Z","dependency_job_id":"75357404-1a11-4b49-9a9f-23e09601805a","html_url":"https://github.com/maoueh/zap-pretty","commit_stats":{"total_commits":40,"total_committers":6,"mean_commits":6.666666666666667,"dds":0.675,"last_synced_commit":"4b88bc3b769d834eba57a094e062a8d68d9171e8"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maoueh%2Fzap-pretty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maoueh%2Fzap-pretty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maoueh%2Fzap-pretty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maoueh%2Fzap-pretty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maoueh","download_url":"https://codeload.github.com/maoueh/zap-pretty/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027411,"owners_count":21035594,"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":["cli","pretty","zap"],"created_at":"2024-10-01T22:47:52.123Z","updated_at":"2025-04-09T11:11:51.951Z","avatar_url":"https://github.com/maoueh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zap-pretty\n\nThis module provides a basic log prettifier for the [zap](https://github.com/uber-go/zap)\nlogging library. It reads a standard Zap JSON log line:\n\n```\n{\"severity\":\"INFO\",\"time\":\"2018-12-10T17:06:24.10107832Z\",\"caller\":\"main.go:45\",\"message\":\"doing some stuff\",\"count\":2}\n```\n\nAnd formats it to:\n\n![](./docs/readme_colored_output.png)\n\n\nThe tool receives JSON lines, determines if they seems like a log line of a supported format\nand pretty print it to standard output.\n\nSupport Zap logging formats:\n- `zap.NewProduction`\n- `zapdriver.NewProduction`\n\n## Install\n\n### Homebrew\n\n```sh\nbrew install maoueh/tap/zap-pretty\n```\n\n### Binary\n\nDownload the binary package for your platform, the list is available at\nhttps://github.com/maoueh/zap-pretty/releases.\n\nUnpack the binary somewhere on your disk and ensure the binary is in a\ndirectory included in your $PATH variable.\n\n### Source\n\n```sh\ngo install github.com/maoueh/zap-pretty/cmd/zap-pretty@latest\n```\n\n**Note** Source installation requires Go 1.16+.\n\n## Usage\n\nSimply pipe the output of the CLI tool generating Zap JSON log lines to the `zap-pretty` tool:\n\n```sh\nzap_instrumented | zap-pretty\n```\n\nThe tool supports Zap standard production format as well as the Zapdriver standard format (for\nconsumption by Google Stackdriver).\n\n### Zapdriver\n\nWhen using the Zapdriver format, those fields are removed by default from the prettified version\nto reduce the clutter of the logs:\n\n- `labels`\n- `serviceContext`\n- `logging.googleapis.com/labels`\n- `logging.googleapis.com/sourceLocation`\n\nIf you want to see those fields, you can use `--all` flag:\n\n```sh\nzap_instrumented | zap-pretty --all\n```\n\n### CLI Arguments\n\n- `--all` - Show all fields of the line, even those filtered out by default for the active logger format (default `false`).\n- `--version` - Show version information.\n- `-n` - Format JSON as multiline if got more than n elements in data (default 3).\n\n### Troubleshoot\n\n#### No Conversion\n\nBy default, when using `zap.NewProductionConfig()`, all log statements are issued on\nthe `/dev/stderr` stream. That means that if you plainly do `zap_instrumented | zap-pretty`,\nyour JSON lines will not be prettified.\n\nWhy? Simply because you are actually piping only the `stdout` stream to `zap-pretty`\nbut your actual log statements are written on `stderr` so they never make their way\nup to `zap-pretty`.\n\nEnsures that JSON line you are seeing is redirected to standard output, if it works\nwhen doing `zap_instrumented 2\u003e\u00261 | zap-pretty`, then it means logs are going out\nto `stderr`.\n\nYou can live like this, but if you want to customize your logs to output to `stdout`\ninstead, simply perform the following changes:\n\n```\n    return zap.NewProduction()\n```\n\nTo:\n\n```\n    config := zap.NewProductionConfig()\n    config.OutputPaths = []string{\"stdout\"}\n    config.ErrorOutputPaths = []string{\"stdout\"}\n\n    return config.Build()\n```\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaoueh%2Fzap-pretty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaoueh%2Fzap-pretty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaoueh%2Fzap-pretty/lists"}