From 870c9f51bee45e973d2c2cb4f8a9eec906d44bcc Mon Sep 17 00:00:00 2001 From: "Fred T. Hamster" Date: Fri, 26 Jan 2024 09:26:24 -0500 Subject: [PATCH] added timestamper function --- scripts/core/functions.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index b39a9d30..6cf06bef 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -32,6 +32,13 @@ if [ -z "$skip_all" ]; then if [ -z "$sep" ]; then sep='_'; fi date +"%Y$sep%m$sep%d$sep%H%M$sep%S" | tr -d '/\n/' } + + # a slightly different but also handy time and date function. this is + # intended for prefixing on log lines, so that each line has the time it + # occurred as the first element. + function timestamper() { + date +"[%Y-%m-%d %H:%M:%S] " | tr -d '/\n/' + } # a wrapper for the which command that finds items on the path. some OSes # do not provide which, so we want to not be spewing errors when that -- 2.34.1