-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.sh
47 lines (39 loc) · 1 KB
/
logger.sh
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
#!/bin/sh
# Ignore warnings that are not important for bash
# shellcheck disable=SC3000-SC4000
SCRIPTENTRY(){
timeAndDate=$(date)
script_name=$(basename "$0")
script_name="${script_name%.*}"
echo "[$timeAndDate] [DEBUG] > $script_name ${FUNCNAME[0]}" >> "$SCRIPT_LOG"
}
SCRIPTEXIT(){
script_name=$(basename "$0")
script_name="${script_name%.*}"
echo "[$timeAndDate] [DEBUG] < $script_name ${FUNCNAME[0]}" >> "$SCRIPT_LOG"
}
ENTRY(){
local cfn="${FUNCNAME[1]}"
timeAndDate=$(date)
echo "[$timeAndDate] [DEBUG] > $cfn ${FUNCNAME[0]}" >> "$SCRIPT_LOG"
}
EXIT(){
local cfn="${FUNCNAME[1]}"
timeAndDate=$(date)
echo "[$timeAndDate] [DEBUG] < $cfn ${FUNCNAME[0]}" >> "$SCRIPT_LOG"
}
INFO(){
local msg="$1"
timeAndDate=$(date)
echo "[$timeAndDate] [INFO] $msg" >> "$SCRIPT_LOG"
}
DEBUG(){
local msg="$1"
timeAndDate=$(date)
echo "[$timeAndDate] [DEBUG] $msg" >> "$SCRIPT_LOG"
}
ERROR(){
local msg="$1"
timeAndDate=$(date)
echo "[$timeAndDate] [ERROR] $msg" >> "$SCRIPT_LOG"
}