Skip to content

Commit

Permalink
Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
michurin committed Jun 16, 2024
1 parent 90cbe56 commit 6730f23
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ PPLOG_LOGLINE='
}}\e[33m{{.K}}\e[0m={{.V}} {{ end }}
'

PPLOG_ERRLINE='{{ if .binary }}{{ .text }}{{ else }}\e[97m{{ .text }}\e[0m{{ end }}'
PPLOG_ERRLINE='{{ if .BINARY }}{{ .TEXT }}{{ else }}\e[97m{{ .TEXT }}\e[0m{{ end }}'
```

My original logs look like this:
Expand Down Expand Up @@ -109,15 +109,15 @@ Now create your first `pplog.env`. You can start from this universal one:

```sh
PPLOG_LOGLINE='{{range .ALL}}{{.K}}={{.V}} {{end}}'
PPLOG_ERRLINE='Invalid JONS: {{.text}}'
PPLOG_ERRLINE='Invalid JONS: {{.TEXT}}'
```

You will see all your logs in KEY=VALUE format. Now look over all your keys and choose one you want
to see in the first place. Say, `message`. Modify your `pplog.env` this way:

```sh
PPLOG_LOGLINE='{{.message}}{{range .ALL | rm "message"}} {{.K}}={{.V}}{{end}}'
PPLOG_ERRLINE='Invalid JONS: {{.text}}'
PPLOG_ERRLINE='Invalid JONS: {{.TEXT}}'
```

You will see `message` in the first place and remove it from KEY=VALUE tail.
Expand All @@ -126,15 +126,16 @@ Now, you are free to add colors:

```sh
PPLOG_LOGLINE='\e[32m{{.message}}\e[m{{range .ALL | rm "message"}} {{.K}}={{.V}}{{end}}'
PPLOG_ERRLINE='Invalid JONS: {{.text}}'
PPLOG_ERRLINE='Invalid JONS: {{.TEXT}}'
```

We makes `message` green. Keep shaping your logs field by field.

## Template functions

- `tmf`
- `rm`
- `trimSpaces` — example: `PPLOG_ERRLINE='INVALID: {{ .TEXT | trimSpace | printf "%q" }}'`
- `tmf` — example: `{{ .A | tmf "2006-01-02T15:04:05Z07:00" "15:04:05" }}`
- `rm` — example: `{{ range .ALL | rm "A" "B" "C" }}{{.K}}={{.V}};{{end}}`
- `rmByPfx`
- `xjson`
- `xxjson` (experimental)
Expand Down

0 comments on commit 6730f23

Please sign in to comment.