summaryrefslogblamecommitdiffstats
path: root/helper/logging.inc
blob: eb20775c2513dd6fd9e5badf6e10a4c43920f16c (plain) (tree)
1
2
3
4
5
6
7
8
9
10
 


                                                      

            

         

                        
                   

              



                                                  



                
                                           



                              




           
                                                                
 
 
            
                                                               

                
 
              
                                                                


            
                                          
                                                  
            
                                                                       


          

      

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