aboutsummaryrefslogtreecommitdiff
path: root/bin/ak-log-message
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-03-31 12:00:59 +0300
committerkaotisk <kaotisk@arching-kaos.org>2024-03-31 12:00:59 +0300
commite4f18be94261b39544ef3bc50321f6aedeb45bd6 (patch)
tree2c79daf0bdc91beb91846f00bb3d3f51236967cf /bin/ak-log-message
parent23a61661f03c03a357ad8aa47ba3595fabe24de1 (diff)
downloadarching-kaos-tools-e4f18be94261b39544ef3bc50321f6aedeb45bd6.tar.gz
arching-kaos-tools-e4f18be94261b39544ef3bc50321f6aedeb45bd6.tar.bz2
arching-kaos-tools-e4f18be94261b39544ef3bc50321f6aedeb45bd6.zip
huge refactor, might breaking things
Diffstat (limited to 'bin/ak-log-message')
-rwxr-xr-xbin/ak-log-message47
1 files changed, 47 insertions, 0 deletions
diff --git a/bin/ak-log-message b/bin/ak-log-message
new file mode 100755
index 0000000..b225313
--- /dev/null
+++ b/bin/ak-log-message
@@ -0,0 +1,47 @@
+#!/bin/bash
+PROGRAM="$(basename $0)"
+TS="$(date -u +%s)"
+if [ ! -z $1 ] && [ -n "$1" ]
+then
+ if [ "$1" == "-h" ] || [ "$1" == "--help" ]
+ then
+ echo "$PROGRAM - Log events"
+ echo "-h, --help Prints this message"
+ echo "<program> <type> <message> Logs this message"
+ exit 0
+ fi
+ if [ ! -z "$2" ] && [ -n "$2" ]
+ then
+ if [ ! -z "$3" ] && [ -n "$3" ]
+ then
+ echo "$TS" "<$1>" "[$2]" "$3" >> $AK_LOGSFILE
+ if [ "$AK_DEBUG" == "yes" ]
+ then
+ echo "$TS" "<$1>" "[$2]" "$3" >&2
+ fi
+ exit 0
+ else
+ echo "$TS" "<$1>" "[ERROR]" "No message" >> $AK_LOGSFILE
+ if [ "$AK_DEBUG" == "yes" ]
+ then
+ echo "$TS" "<$1>" "[ERROR]" "No message" >&2
+ fi
+ exit 1
+ fi
+ else
+ echo "$TS" "<$1>" "[ERROR]" "No type and message" >> $AK_LOGSFILE
+ if [ "$AK_DEBUG" == "yes" ]
+ then
+ echo "$TS" "<$1>" "[ERROR]" "No type and message" >&2
+ fi
+ exit 1
+ fi
+else
+ echo "$TS" "<$(basename $0)>" "[ERROR]" "No arguments given" >> $AK_LOGSFILE
+ if [ "$AK_DEBUG" == "yes" ]
+ then
+ echo "$TS" "<$(basename $0)>" "[ERROR]" "No arguments given" >&2
+ fi
+ exit 1
+fi
+