[Release] Webkit2-efl-123997_0.11.28
[framework/web/webkit-efl.git] / TizenScripts / find-tizen-logs
1 #!/bin/bash
2
3 for LOG_MACRO in TIZEN_LOGI TIZEN_LOGE AlogInfo AlogError; do
4
5 # Find files containing TIZEN_LOG[IE] macro.
6 LOG=$LOG_MACRO
7 FILES=`grep -lr "$LOG[\(,][^.]" Source/`
8 echo ""
9 echo "******************"
10 echo "*** $LOG ***"
11 echo "******************"
12
13 # Process each file.
14 for file in $FILES; do
15
16     # Print file name.
17     echo ""
18     echo "$file:"
19
20     # Get all matches in the file.
21     MATCH_OUTPUT=`grep -hn $LOG $file`
22
23     # Find number of matches.
24     MATCH_COUNT=`echo "$MATCH_OUTPUT" | wc -l`
25
26     # Process matches
27     for (( index=1; index<=$MATCH_COUNT; index++ )); do
28
29         # Find the line of the i-th match
30         LINENUM=`echo "$MATCH_OUTPUT" | head -n $index | tail -n 1 | grep -o "^[0-9]\+"`
31
32         for i in $(seq $LINENUM -1 1); do
33
34             # Find first open brace.
35             LINE=`head -n $i $file | tail -n 1 | grep ^{`
36
37             if [ ! -z $LINE ]; then
38
39                 for j in $(seq $(($i-1)) -1 1); do
40                     # Function name found.
41                     FUNCTION_NAME=`head -n $j $file | tail -n 1`
42                     if [ "`expr \"$FUNCTION_NAME\" : \"^[# ]\"`" == "0" ]; then
43                         break
44                     fi
45                 done
46                 if [ "$FUNCTION_NAME" != "$PREV_FUNCTION_NAME" ]; then
47
48                     # Print function name.
49                     echo ""
50                     echo "    $FUNCTION_NAME"
51
52                 fi
53
54                 # Append log line.
55                 LOG_LINE=`echo "$MATCH_OUTPUT" | head -n $index | tail -n 1`
56                 echo "    $LOG_LINE" | sed "s/  \+/ /g"
57
58                 PREV_FUNCTION_NAME=$FUNCTION_NAME
59                 break
60
61             fi
62
63         done
64
65     done
66
67 done
68
69 done
70
71 exit 0