summaryrefslogtreecommitdiffstats
path: root/helper/logging.inc
blob: eb20775c2513dd6fd9e5badf6e10a4c43920f16c (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
45
46
47
48
49
50
51
52
53

if [ "x$MLTK_QUIET" == "x" ]; then #ifndef _MLTK_QUIET
#define _MLTK_QUIET

MLTK_QUIET=0

exec 6>&2

LOG_DIR=${ROOT_DIR}/logs

mkdir -p "$LOG_DIR"

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

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


pinfo  () {
	echo -e "\033[38;5;10m[info]\033[0m    $TOOL_STR $@" >&6
}

perror () { 
	echo -e "\033[38;5;9m[error]\033[0m   $TOOL_STR $@" >&6
	qnd_exit
}

pwarning  () {
	echo -e "\033[38;5;11m[warning]\033[0m $TOOL_STR $@" >&6
}

pdebug  () {
	if [ "x$MLTK_QUIET" = "x1" ]; then
		echo -e "[DEBUG] $TOOL_STR $@" >&2
	else
		echo -e "\033[38;5;6m[debug]\033[0m   $TOOL_STR $@" >&6
	fi
}

#endif
fi