#!/bin/bash for LOG_MACRO in TIZEN_LOGI TIZEN_LOGE AlogInfo AlogError; do # Find files containing TIZEN_LOG[IE] macro. LOG=$LOG_MACRO FILES=`grep -lr "$LOG[\(,][^.]" Source/` echo "" echo "******************" echo "*** $LOG ***" echo "******************" # Process each file. for file in $FILES; do # Print file name. echo "" echo "$file:" # Get all matches in the file. MATCH_OUTPUT=`grep -hn $LOG $file` # Find number of matches. MATCH_COUNT=`echo "$MATCH_OUTPUT" | wc -l` # Process matches for (( index=1; index<=$MATCH_COUNT; index++ )); do # Find the line of the i-th match LINENUM=`echo "$MATCH_OUTPUT" | head -n $index | tail -n 1 | grep -o "^[0-9]\+"` for i in $(seq $LINENUM -1 1); do # Find first open brace. LINE=`head -n $i $file | tail -n 1 | grep ^{` if [ ! -z $LINE ]; then for j in $(seq $(($i-1)) -1 1); do # Function name found. FUNCTION_NAME=`head -n $j $file | tail -n 1` if [ "`expr \"$FUNCTION_NAME\" : \"^[# ]\"`" == "0" ]; then break fi done if [ "$FUNCTION_NAME" != "$PREV_FUNCTION_NAME" ]; then # Print function name. echo "" echo " $FUNCTION_NAME" fi # Append log line. LOG_LINE=`echo "$MATCH_OUTPUT" | head -n $index | tail -n 1` echo " $LOG_LINE" | sed "s/ \+/ /g" PREV_FUNCTION_NAME=$FUNCTION_NAME break fi done done done done exit 0