summaryrefslogtreecommitdiffstats
path: root/helper/functions.common.sh
blob: de33363cbb992f5da9ff5cc8be5da270281fb212 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

QUIET=0

LOG_DIR=${ROOT_DIR}/logs

mkdir -p $LOG_DIR

set_quiet () {
	if [ "x$DEBUG" != "x1" -a "x$QUIET" != "x1" ]; then
	  exec 6>&1 > $LOG_DIR/stdout.log
	  exec 2>  $LOG_DIR/stderr.log
	  QUIET="1"
	fi
}

unset_quiet () {
	if [ "x$QUIET" = "x1" ]; then
  	  exec 1>&6 6>&-
	  exec 2>&-
	  QUIET="0"
	fi
}


pinfo  () {
	unset_quiet
	echo -e    "[info]  $1"
	set_quiet
}
perror () { 
	unset_quiet
	echo -e    "[error] $1"
	set_quiet
}
pecho  () {
	unset_quiet
	echo -e    "[user]  $1"
	set_quiet
}
pechon () { 
	unset_quiet
	echo -e -n "[user]  $1"
	set_quiet
}