New version of build scripts
[maemo-efl] / trunk / scripts / log-functions.sh
1 #!/bin/sh
2
3 ###########################################################
4 # Maemo-efl building script
5 # Logging functions definitions
6 #
7 # Note: var-definitions.sh and helper-functions.sh needed.
8 ###########################################################
9
10 function create_log_file() {
11     if [ ! -r $__output_file ]; then
12         msg_begin "Creating log file"
13         touch $__output_file
14         msg_end $?
15     else
16         msg "Using existing log file: $__output_file"
17     fi
18 }
19
20 function log_to_file() {
21     local now
22     local msg
23     msg=$1
24
25     if [ ! -r $__output_file ]; then
26         error "log_to_file(): Log file does not exist"
27     fi
28
29     now=`$__date +%H:%M:%S`
30     echo "$now: $msg" >> $__output_file
31 }
32
33 function start_log() {
34     local now
35     now=`$__date -R`
36
37     echo "" >> $__output_file
38
39     if [ $? != 0 ] ; then
40         error "start_log(): Could not create $__output_file file"
41     fi
42
43     cat << EOF >> $__output_file
44 *********************************************************
45 * Started $__this_script: $now *
46 *********************************************************
47
48 EOF
49 }
50
51 function finish_log() {
52     local now
53     now=`$__date -R`
54
55     if [ ! -r $__output_file ]; then
56         error "finish_log(): Log file does not exist"
57     fi
58
59     cat << EOF >> $__output_file
60
61 * Finished $__this_script: $now
62 EOF
63 }
64