From 74371ed5b6abf0a5616d9837542add7e8b85bded Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 5 Jul 2024 09:39:08 +0000 Subject: [PATCH] make.sh: Create a custom log function Signed-off-by: Michael Tremer --- make.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/make.sh b/make.sh index a8855c7c42..f94fb38bda 100755 --- a/make.sh +++ b/make.sh @@ -95,6 +95,21 @@ resize_terminal # Call resize_terminal when terminal is being resized trap "resize_terminal" WINCH +# Writes a line to the log file +log() { + local line="$@" + + # Fetch the current timestamp + local t="$(date -u "+%b %e %T")" + + # Append the line to file + if [ -w "${LOGFILE}" ]; then + echo "${t}: ${line}" >> "${LOGFILE}" + fi + + return 0 +} + find_base() { local path -- 2.47.3