wb-rules
wb-rules copied to clipboard
Fix log priority
- https://github.com/wirenboard/wbgong/pull/17
Test instruction:
$ cat << EOF > /etc/wb-rules/rules.js
log.info('info');
log.warning('warning');
log.error('error');
log.debug('debug');
EOF
$ mqtt-rpc-client -d wb_logs -s logs -m Load -a '{"levels":{"0":6},"service":"wb-rules.service","limit":2}' | jq -r '.[1]|.level,.msg'
null
INFO: [rule info] info
$ mqtt-rpc-client -d wb_logs -s logs -m Load -a '{"levels":{"0":4},"service":"wb-rules.service","limit":1}' | jq -r '.[]|.level,.msg'
4
WARNING: [rule warning] warning
$ mqtt-rpc-client -d wb_logs -s logs -m Load -a '{"levels":{"0":3},"service":"wb-rules.service","limit":1}' | jq -r '.[]|.level,.msg'
3
ERROR: [rule error] error
- enable coverage summary:
coverage: 79.2% of statements
- [minor] fix crash with no args
Before:
$ wb-rules
panic: runtime error: index out of range [1] with length 1
goroutine 1 [running]:
main.main()
github.com/wirenboard/wb-rules/main.go:46 +0x1504
After:
$ wb-rules
ERROR: 2024/10/14 15:25:43 must specify rule file/directory name(s)