diff options
Diffstat (limited to 'lib/_ak_log')
-rwxr-xr-x | lib/_ak_log | 23 |
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 |