blob: b22531376f19d93b33170679f0795fac69adf12d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
|