Skip to content

Commit fc18ab1

Browse files
Create Template-logging.sh
1 parent f8d2c01 commit fc18ab1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Template-logging.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export DEBUG_FLAG=1
2+
Log_Info() {
3+
local timestamp=`date +"%Y%m%d%H%M%S"`
4+
log_message="$timestamp INFO: $1"
5+
test $DEBUG_FLAG -eq 1 && echo "$log_message"
6+
}
7+
Log_Error() {
8+
local timestamp=`date +"%Y%m%d%H%M%S"`
9+
log_message="$timestamp ERROR: $1"
10+
echo "$log_message" 1>&2;
11+
}
12+
Log_Error "This is an error message. Ideally I should be followed by a exit <non-zero-value>."
13+
Log_Info "For your info, I am an info message."

0 commit comments

Comments
 (0)