{"id":19484478,"url":"https://github.com/flowerinthenight/pretty","last_synced_at":"2025-04-25T16:33:45.024Z","repository":{"id":41812674,"uuid":"132991980","full_name":"flowerinthenight/pretty","owner":"flowerinthenight","description":"A simple JSON log prettifier tool.","archived":false,"fork":false,"pushed_at":"2018-05-12T19:21:05.000Z","size":32,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-20T12:39:17.327Z","etag":null,"topics":["go","golang","json","prettifier","pretty-print","stderr","stdout"],"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/flowerinthenight.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":"2018-05-11T05:07:46.000Z","updated_at":"2023-10-03T14:59:17.000Z","dependencies_parsed_at":"2022-09-11T10:40:31.472Z","dependency_job_id":null,"html_url":"https://github.com/flowerinthenight/pretty","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/flowerinthenight%2Fpretty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flowerinthenight%2Fpretty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flowerinthenight%2Fpretty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flowerinthenight%2Fpretty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flowerinthenight","download_url":"https://codeload.github.com/flowerinthenight/pretty/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224009483,"owners_count":17240568,"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":["go","golang","json","prettifier","pretty-print","stderr","stdout"],"created_at":"2024-11-10T20:22:00.956Z","updated_at":"2024-11-10T20:22:01.939Z","avatar_url":"https://github.com/flowerinthenight.png","language":"Go","readme":"## Overview\n\n`pretty` is a simple wrapper tool that prettifies a process's stdout/stderr's JSON output line by line. If output line is not a valid JSON, or does not contain a valid JSON, it will just print the line as is. It also works in \"follow\" mode, such as `tail -f ...` or `kubectl logs -f ...`.\n\nIt also works with https://github.com/wercker/stern (which I use a lot), that is, the JSON log has a text prefix (pod name in `stern`'s case). It will print the text prefix first, then append the prettified JSON. To enable color for `stern`, you can try the following command:\n\n```bash\n$ pretty --stern=true -- stern \u003csome-pod/svc\u003e -s 24h\n```\n\nExample: (normal JSON logs using logrus, redacted)\n\n```bash\n$ kubectl logs -f svc-699544fd4d-zzlcf\n...\n{\"action\":\"describe-deployments\",\"http_method\":\"GET\",\"level\":\"info\",\"service\":\"stack\",\"time\":\"...\"...}\n{\"context\":\"metrics-middleware\",\"http_method\": \"GET\",\"level\":\"info\",\"service\":\"stack\",\"time\":\"...\"...}\n{\"action\": \"encode-response\",\"http_method\": \"GET\",\"level\": \"info\",\"msg\": \"marshal response as is\"...}\n...\n```\n\nExample: (wrapped by pretty, redacted)\n\n```bash\n$ pretty -- kubectl logs -f svc-699544fd4d-zzlcf\n...\n2018/05/11 14:58:45 [stdout] {\n  \"action\": \"describe-deployments\",\n  \"http_method\": \"GET\",\n  \"level\": \"info\",\n  \"msg\": \"describe={Type:compute.v1.instance Zone:asia-northeast1-a Name:...}\",\n  \"request\": \"92b86ab1-7c8e-4f77-871a-7caf132b421e\",\n  \"service\": \"stack\",\n  \"time\": \"2018-05-11T05:58:45Z\"\n}\n2018/05/11 14:58:45 [stdout] {\n  \"context\": \"metrics-middleware\",\n  \"http_method\": \"GET\",\n  \"level\": \"info\",\n  \"msg\": \"fn=DescribeDeployment, duration=1.561291986s\",\n  \"request\": \"92b86ab1-7c8e-4f77-871a-7caf132b421e\",\n  \"service\": \"stack\",\n  \"time\": \"2018-05-11T05:58:45Z\"\n}\n2018/05/11 14:58:45 [stdout] {\n  \"action\": \"encode-response\",\n  \"http_method\": \"GET\",\n  \"level\": \"info\",\n  \"msg\": \"marshal response as is\",\n  \"request\": \"92b86ab1-7c8e-4f77-871a-7caf132b421e\",\n  \"time\": \"2018-05-11T05:58:45Z\"\n}\n...\n```\n\n## Installation\n\n```bash\n$ go get -u -v github.com/flowerinthenight/pretty\n```\n\n## Usage\n\nYou can prepend the command that you want to prettify with `pretty [flags] --`. The double-dash will ensure that any succeeding flags belong to the wrapped command, not to `pretty`.\n\n```bash\n$ pretty -- kubectl logs -f svc-699544fd4d-zzlcf\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflowerinthenight%2Fpretty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflowerinthenight%2Fpretty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflowerinthenight%2Fpretty/lists"}