Blame view
tools/scripts/Tools.sh
1.77 KB
e6be5137b reinitialized pro... |
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
#!/bin/bash ################################################# # File : Tools.sh # # Brief : Tool functions # # Author : Jean-François Rey # # Version : 1.0 # # Date : 13/06/13 # ################################################# # Type ERROR=2 WARN=1 INFO=0 # Global Verbose variable (have to be define in scripts) # 0 : mute # 1 : basic info (start,config,end) # 2 : add process # 3 : all VERBOSE=0 # print_message( verbose_level, message) # - message_type : ERROR, WARN, INFO # - verbose_level : level to print message # - message : the message to print function print_message() { if [ $# -eq 3 ] then # print error if [ $1 -eq $ERROR ]; then echo -ne "###ERROR : $3 " > 2; fi # check verbose level if [ $2 -le $VERBOSE ] then for (( dec=1 ; $dec<$2 ; dec++ )); do echo -ne "\t"; done # print warn if [ $1 = $WARN ]; then echo -ne "##WARNING : $3 "; fi # default info echo -ne "#INFO : $3 " fi fi } # print_error(message) # - message : error message to print function print_error() { print_message $ERROR 3 "$1" } # print_warn(message,[level]) # - message : message to print # - level : optional option - verbose level to print function print_warn() { if [ $# -eq 2 ] then print_message $WARN $2 "$1" else print_message $WARN $VERBOSE "$1" fi } # print_info(message,[level]) # - message : message to print # - level : optional option - verbose level to print function print_info() { if [ $# -eq 2 ] then print_message $INFO $2 "$1" else print_message $INFO $VERBOSE "$1" fi } |