Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A simple JSON log prettifier tool.

License

NotificationsYou must be signed in to change notification settings

flowerinthenight/pretty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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 astail -f ... orkubectl logs -f ....

It also works withhttps://github.com/wercker/stern (which I use a lot), that is, the JSON log has a text prefix (pod name instern's case). It will print the text prefix first, then append the prettified JSON. To enable color forstern, you can try the following command:

$ pretty --stern=true -- stern<some-pod/svc> -s 24h

Example: (normal JSON logs using logrus, redacted)

$ kubectl logs -f svc-699544fd4d-zzlcf...{"action":"describe-deployments","http_method":"GET","level":"info","service":"stack","time":"..."...}{"context":"metrics-middleware","http_method":"GET","level":"info","service":"stack","time":"..."...}{"action":"encode-response","http_method":"GET","level":"info","msg":"marshal response as is"...}...

Example: (wrapped by pretty, redacted)

$ pretty -- kubectl logs -f svc-699544fd4d-zzlcf...2018/05/11 14:58:45 [stdout] {"action":"describe-deployments","http_method":"GET","level":"info","msg":"describe={Type:compute.v1.instance Zone:asia-northeast1-a Name:...}","request":"92b86ab1-7c8e-4f77-871a-7caf132b421e","service":"stack","time":"2018-05-11T05:58:45Z"}2018/05/11 14:58:45 [stdout] {"context":"metrics-middleware","http_method":"GET","level":"info","msg":"fn=DescribeDeployment, duration=1.561291986s","request":"92b86ab1-7c8e-4f77-871a-7caf132b421e","service":"stack","time":"2018-05-11T05:58:45Z"}2018/05/11 14:58:45 [stdout] {"action":"encode-response","http_method":"GET","level":"info","msg":"marshal response as is","request":"92b86ab1-7c8e-4f77-871a-7caf132b421e","time":"2018-05-11T05:58:45Z"}...

Installation

$ go get -u -v github.com/flowerinthenight/pretty

Usage

You can prepend the command that you want to prettify withpretty [flags] --. The double-dash will ensure that any succeeding flags belong to the wrapped command, not topretty.

$ pretty -- kubectl logs -f svc-699544fd4d-zzlcf

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp