From a3b8341b75eb4c1eb990a689094965ad834d99c6 Mon Sep 17 00:00:00 2001 From: ssube Date: Sat, 2 Nov 2019 11:25:12 -0500 Subject: [PATCH] fix(docs): note pretty-printing logs --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index a3ff23f..3b40cca 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ supports multiple documents per stream or file, inserting defaults, and other ma - [Global](#global) - [Project](#project) - [Usage](#usage) + - [Logs](#logs) - [Modes](#modes) - [Check Mode](#check-mode) - [Fix Mode](#fix-mode) @@ -171,6 +172,34 @@ To run with Node: ## Usage +### Logs + +`salty-dog` uses [node-bunyan](https://github.com/trentm/node-bunyan) for logging and prints JSON logs. These are not +the easiest to read, and can be pretty-printed by redirecting `stderr` through `bunyan` itself or `jq`: + +```shell +> cat resource.yml | salty-dog --rules rules/kubernetes.yml --tag kubernetes 2> >(bunyan) + +... +[2019-06-15T23:53:34.223Z] INFO: salty-dog/19839 on cerberus: all rules passed + +> cat resource.yml | salty-dog --rules rules/kubernetes.yml --tag kubernetes 2> >(jq) + +... +{ + "name": "salty-dog", + "hostname": "cerberus", + "pid": 19839, + "level": 30, + "msg": "all rules passed", + "time": "2019-06-15T23:53:34.223Z", + "v": 0 +} +``` + +Using `jq` allows for additional filtering, for example `>(jq 'select(.level > 30)')` will only print warnings and +errors (log level is also part of the configuration file). + ### Modes `salty-dog` can run in a few different modes: `check` mode will report errors, `fix` mode will attempt to modify the