Make writing to log file and showing terminal output depending on logging level

This commit is contained in:
icenine451 2024-10-18 09:25:54 -04:00
parent 3d19ea6a14
commit 2e1a461855

View file

@ -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"
}