From 2e1a4618550137d6365875613e3acf84e043761d Mon Sep 17 00:00:00 2001 From: icenine451 Date: Fri, 18 Oct 2024 09:25:54 -0400 Subject: [PATCH] Make writing to log file and showing terminal output depending on logging level --- functions/logger.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/functions/logger.sh b/functions/logger.sh index 9c2ea6c3..0b59cd65 100755 --- a/functions/logger.sh +++ b/functions/logger.sh @@ -85,14 +85,15 @@ log() { ;; esac - # Display the message in the terminal - echo -e "$colored_message" >&2 + if [[ ! $logging_level == "none" ]]; then + # Display the message in the terminal + echo -e "$colored_message" >&2 - # Write the log message to the log file - if [ ! -f "$logfile" ]; then - echo "$timestamp [WARN] Log file not found in \"$logfile\", creating it" >&2 - touch "$logfile" + # Write the log message to the log file + if [ ! -f "$logfile" ]; then + echo "$timestamp [WARN] Log file not found in \"$logfile\", creating it" >&2 + touch "$logfile" + fi + echo "$log_message" >> "$logfile" fi - echo "$log_message" >> "$logfile" - }