From c8ec86082c56ceb59a268dad8d50c04db4fe0440 Mon Sep 17 00:00:00 2001 From: bakerboy448 <55419169+bakerboy448@users.noreply.github.com> Date: Sun, 11 Aug 2024 14:01:02 -0500 Subject: [PATCH] xseed.sh v2.1.1 fix initial logging don't tee if log file not yet ingested --- xseed.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xseed.sh b/xseed.sh index e4313ac..6bd4458 100755 --- a/xseed.sh +++ b/xseed.sh @@ -8,7 +8,7 @@ # Load environment variables from .env file if it exists # in the same directory as this bash script -VERSION='2.1.0' +VERSION='2.1.1' SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ENV_PATH="$SCRIPT_DIR/.env" @@ -16,8 +16,14 @@ ENV_PATH="$SCRIPT_DIR/.env" log_message() { local log_type="$1" local message="$2" - echo "$(date '+%Y-%m-%d %H:%M:%S') [$log_type] $message" | tee -a "$LOG_FILE" + local log_line="$(date '+%Y-%m-%d %H:%M:%S') [$log_type] $message" + if [ -f "$LOG_FILE" ]; then + echo "$log_line" | tee -a "$LOG_FILE" + else + echo "$log_line" + fi } + log_message "INFO" "xseed.sh script started $VERSION" EVAR=false if [ -f "$ENV_PATH" ]; then