aboutsummaryrefslogtreecommitdiff
path: root/contrib/scripts/process_log.sh
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/scripts/process_log.sh')
-rwxr-xr-xcontrib/scripts/process_log.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/contrib/scripts/process_log.sh b/contrib/scripts/process_log.sh
new file mode 100755
index 000000000..c25c515c2
--- /dev/null
+++ b/contrib/scripts/process_log.sh
@@ -0,0 +1,30 @@
1#!/bin/bash
2
3# Usage: service should print "STARTING SERVICE (srvc) for peer [PEER]" where:
4# - "srvc" is the service name (in lowercase, as in the log output).
5# It cannot contain parenthesis in its name.
6# - "PEER" is the peer ID. Should be 4 alfanumeric characters
7
8grep "STARTING SERVICE " log > __tmp_peers
9
10SED_EXPR=""
11while read -r line; do
12 SRVC=`echo "$line" | sed -e 's/.*(\([^)]*\)).*/\1/'`
13 PEER=`echo "$line" | sed -e 's/.*\[\(....\)\].*/\1/'`
14 PID=`echo "$line" | sed -e "s/.*$SRVC-\([0-9]*\).*/\1/"`
15 echo "$SRVC $PID => $PEER"
16
17 SED_EXPR="${SED_EXPR}s/$SRVC-\([a-z2]*\)-$PID/$SRVC \1 $PEER/;"
18 SED_EXPR="${SED_EXPR}s/$SRVC-$PID/$SRVC XXX $PEER/;"
19 SED_EXPR="${SED_EXPR}s/$SRVC-api-[0-9]/$SRVC-api- /;"
20done < __tmp_peers
21rm __tmp_peers
22
23sed -e "$SED_EXPR" log > .log
24echo "$0 sed regex: $SED_EXPR" >> .log
25
26SIZE=`stat -c%s .log`
27
28if [[ "`ps aux | grep "kwrite .lo[g]"`" = "" && "$SIZE" < 10000000 ]]; then
29 kwrite .log --geometry 960x1140-960 &
30fi