-
Notifications
You must be signed in to change notification settings - Fork 0
/
README_JSON
47 lines (36 loc) · 3.31 KB
/
README_JSON
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
┏━━━━━━━━━━━━━━━━┓
┃ 2024-11-03 ┃
┗━━━━━━━━━━━━━━━━┛
This is a note for myself before I create yet *another* script to conver the log output
to jq-compatible output.
There are *THREE* scripts that do this:
What's kind of funny is that I did the last one over a year after the first two and solved it
the exact same way.
jq_log
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░
░ #!/bin/bash
░ # Convert logs to JSON array and feed into jq so I can just see certain fields
░ #cat <(echo "[") <(sed -e 's/.*/&,/' logs/gerlshmud.log) <(echo "{}]") | jq --compact-output -a '.[] | {pid, id, owner, message, event_type}'
░ #cat <(echo "[") <(sed -e 's/.*/&,/' logs/gerlshmud.log) <(echo "{}]") | jq --compact-output -a '.[] | select(.id == "room") | {pid, id, owner, character, stage, event_type, message}'
░ #cat <(echo "[") <(sed -e 's/.*/&,/' logs/gerlshmud.log) <(echo "{}]") | jq --compact-output -a '.[] | {pid, id, owner, character, stage, event_type, message}'
░ #cat <(echo "[") <(sed -e 's/.*/&,/' logs/gerlshmud.log) <(echo "{}]") | jq --compact-output -a '.[] | select(.event_type != "populate") | {pid, id, name, owner, character, stage, event_type, conn, message}'
░ cat <(echo "[") <(sed -e 's/.*/&,/' logs/gerlshmud.log) <(echo "{}]") | jq --compact-output -a '.[] | select(.event_type != "populate") | {pid, id, conn, event_type, stage, message}'
░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
jq_raw
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░
░ #!/bin/bash
░ # Convert logs to JSON array and feed into jq so I can just see certain fields
░ #cat <(echo "[") <(sed -e 's/.*/&,/' logs/egre_mud_1.log) <(echo "{}]") | jq --compact-output -a '.[] | {pid, id, owner, message, event_type}'
░ #cat <(echo "[") <(sed -e 's/.*/&,/' logs/egre_mud_1.log) <(echo "{}]") | jq --compact-output -a '.[] | select(.id == "room") | {pid, id, owner, character, stage, event_type, message}'
░ cat <(echo "[") <(sed -e 's/.*/&,/' logs/egre_mud_1.log) <(echo "{}]") | jq --compact-output -a '.[]'
░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
log_to_json
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░
░ cat <(echo "[") <(sed -e 's/$/,/' logs/egre.log) <(echo "{}]") > jq_json
░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░