nice new tool to show version of feisty meow
[feisty_meow.git] / scripts / buildor / check_java_logger.sh
1 #!/bin/bash
2
3 # looks for occurrences of getting a Log from the log factory.  when we find
4 # one, we make sure it is using the same class name as the compilation unit.
5
6 file="$1"; shift
7
8 if [ -z "$file" -o ! -f "$file" ]; then
9   echo This script needs a filename to check for appropriate logger creation.
10   echo Any file that has a Log based on a different class than itself will
11   echo be reported.
12   exit 1
13 fi
14
15 class_in_logger="$(sed -n -e 's/.*LogFactory.getLog( *\([^\.]*\)\.class *).*/\1/p' <"$file")"
16
17 #echo got class from logger of $class_in_logger
18
19 if [ -z "$class_in_logger" ]; then
20   # we didn't find a log factory.
21   exit 0
22 fi
23
24 base_of_class="$(basename "$file" | sed -e 's/\(.*\)\.java/\1/')"
25
26 #echo base of class is $base_of_class
27
28 if [ "$class_in_logger" != "$base_of_class" ]; then
29   echo "$file"
30   exit 1
31 fi
32
33