-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog_error.sh
More file actions
executable file
·32 lines (23 loc) · 788 Bytes
/
Copy pathlog_error.sh
File metadata and controls
executable file
·32 lines (23 loc) · 788 Bytes
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
#!/usr/bin/env bash
# Get the directory of the current script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$SCRIPT_DIR/load_color_codes.def"
log_error() {
# Fields
# ERROR
# Datestamp
# Hostname
# Script name
# Error message
DATESTAMP_NOW=$(date "+%Y-%m-%d %H:%M:%S %a")
script_name=$(basename "${BASH_SOURCE[1]:-$0}")
printf '[ERROR] [%s] [%s] [%s] %s\n' "${DATESTAMP_NOW}" "${HOSTNAME}" "${script_name}" "$*" 1>&2
return 1
}
# Source footer if it exists
if [ -f "$SCRIPT_DIR/bash_footer.template.live" ]; then
source "$SCRIPT_DIR/bash_footer.template.live"
else
echo -e "${RED}Footer template missing. Skipping...${RESET}"
echo -e "Please ensure 'bash_footer.template.live' exists in the same directory."
fi