Skip to content

Commit 497d6fb

Browse files
Calculate the log dir path inside the create_log_entry
1 parent 9441244 commit 497d6fb

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

alerts/sender_with_alert.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,21 @@ function send_slack_message() {
7979
. alerts/slack.sh "$1"
8080
}
8181

82-
LOG_DIR_PATH="./alerts/notification_logs/log_$date_only.txt"
8382
# Creates a log entry in the daily log file
8483
function create_log_entry() {
8584
status="$1"
8685
reason="${2:-}"
8786

8887
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
8988

90-
# Keep the date to get the file name
91-
date_only=$(date +"%Y_%m_%d")
89+
log_file_path="./alerts/notification_logs/log_$(date +"%Y_%m_%d").txt"
9290

9391
# Check if file exists, if not create it
94-
if [ ! -f "$LOG_DIR_PATH" ]; then
95-
touch "$LOG_DIR_PATH"
92+
if [ ! -f "$log_file_path" ]; then
93+
touch "$log_file_path"
9694
fi
9795

98-
echo "[$timestamp] $status: - $reason" >> "$LOG_DIR_PATH"
96+
echo "[$timestamp] $status: - $reason" >> "$log_file_path"
9997
}
10098

10199
################# SEND LOGIC #################

0 commit comments

Comments
 (0)