]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
make.sh: Create a custom log function
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 Jul 2024 09:39:08 +0000 (09:39 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 Jul 2024 15:39:44 +0000 (15:39 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
make.sh

diff --git a/make.sh b/make.sh
index a8855c7c4232ad1977779d6b604b1586115534ce..f94fb38bda78e4d173d95bbdef864d6727fd8bcc 100755 (executable)
--- 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