aboutsummaryrefslogtreecommitdiff
path: root/lib/_ak_log
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-07-04 18:36:54 +0300
committerkaotisk <kaotisk@arching-kaos.org>2024-07-04 18:36:54 +0300
commitc0dbfc8dc7cf7af278de1d233d87ffbe481ba704 (patch)
tree9037aef8094102626f387cec6d026793478fd53a /lib/_ak_log
parent2d04f1e16cd234b6ad82eff3c4cd6b09149ef4ec (diff)
downloadarching-kaos-tools-c0dbfc8dc7cf7af278de1d233d87ffbe481ba704.tar.gz
arching-kaos-tools-c0dbfc8dc7cf7af278de1d233d87ffbe481ba704.tar.bz2
arching-kaos-tools-c0dbfc8dc7cf7af278de1d233d87ffbe481ba704.zip
Refactoring + bug fixes
- Recursive sourcing was introduced and fixed - Almost finished removing old style commands 'ak-zchain-chk' in favor of the new design (eg 'ak zchain --check') - A couple of changes on how we really do concatenation of an IPFS link - Interface function for publishing to 'ak-config' key - Interface function for publishing to IPNS keys
Diffstat (limited to 'lib/_ak_log')
-rwxr-xr-xlib/_ak_log23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/_ak_log b/lib/_ak_log
index c598ab8..df144bd 100755
--- a/lib/_ak_log
+++ b/lib/_ak_log
@@ -1,17 +1,24 @@
#!/bin/bash
-_ak_log_follow(){
- tail -f $AK_LOGSFILE | while read -r p || [ -n "$p" ]
- do
- timestamp="$(echo "$p" | awk '{print $1}')"
- program="$(echo "$p" | awk '{print $2}')"
- messagetype="$(echo "$p" | awk '{print $3}')"
- message="$(echo "$p" | cut -d ' ' -f4-)"
+_ak_log_print_log_line(){
+ if [ -n "$1" ]
+ then
+ timestamp="$(echo "$*" | awk '{print $1}')"
+ program="$(echo "$*" | awk '{print $2}')"
+ messagetype="$(echo "$*" | awk '{print $3}')"
+ message="$(echo "$*" | cut -d ' ' -f4-)"
printf '%s \033[1;32m%s\033[0;00m \033[1;31m%s\033[0;00m %s\n' \
"$(date --date=@$timestamp +%Y%m%d_%H%M%S)" \
"$program" \
"$messagetype" \
"$message"
+ fi
+}
+
+_ak_log_follow(){
+ tail -f $AK_LOGSFILE | while read -r p || [ -n "$p" ]
+ do
+ _ak_log_print_log_line "$p"
done
}
@@ -60,7 +67,7 @@ _ak_log_message(){
echo "$TS" "<$1>" "[$2]" "$msg" >> $AK_LOGSFILE
if [ ! -z $AK_DEBUG ] && [ -n "$AK_DEBUG" ] && [ "$AK_DEBUG" == "yes" ]
then
- echo "$TS" "<$1>" "[$2]" "$msg" >&2
+ _ak_log_print_log_line "$TS <$1> [$2] $msg" >&2
fi
else
echo "$TS" "<$1>" "[ERROR]" "No message" >> $AK_LOGSFILE