aboutsummaryrefslogtreecommitdiff
path: root/lib/_ak_log
diff options
context:
space:
mode:
Diffstat (limited to 'lib/_ak_log')
-rwxr-xr-xlib/_ak_log35
1 files changed, 30 insertions, 5 deletions
diff --git a/lib/_ak_log b/lib/_ak_log
index 51064e7..9d4f8c3 100755
--- a/lib/_ak_log
+++ b/lib/_ak_log
@@ -75,6 +75,21 @@ function _ak_log_print_log_line(){
fi
}
+function _ak_log_print_log_line_irc(){
+ 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 '\x0300,01%s \x0303,01%s\x0300,01 \x0304,01%s\x0300,01 %s\x0301,00\n' \
+ "$(_ak_datetime_unix_to_human $timestamp)" \
+ "$program" \
+ "$messagetype" \
+ "$message"
+ fi
+}
+
function _ak_log_follow(){
tail -f $AK_LOGSFILE | while read -r p || [ -n "$p" ]
do
@@ -140,13 +155,23 @@ function _ak_log_message(){
then
echo "$TS" "<$prg>" "[$tp]" "$msg" >> $AK_LOGSFILE
fi
- if [ ! -z $AK_DEBUG ] && [ -n "$AK_DEBUG" ] && [ "$AK_DEBUG" == "yes" ]
+ if [ ! -z $AK_DEBUG ] && [ -n "$AK_DEBUG" ] # && [ $AK_DEBUG -gt 0 ]
then
+ case $tp in
+ INFO) if [[ $AK_DEBUG -lt 1 ]]; then return ;fi ;;
+ # ERROR) if [[ $AK_DEBUG -lt 2 ]]; then return ;fi ;;
+ WARNING) if [[ $AK_DEBUG -lt 3 ]]; then return ;fi ;;
+ DEBUG|EXIT) if [[ $AK_DEBUG -lt 5 ]]; then return ;fi ;;
+ esac
_ak_log_print_log_line "$TS <$prg> [$tp] $msg" >&2
fi
+ if [ ! -z $AK_DEBUG_IRC ] && [ -n "$AK_DEBUG_IRC" ] && [ "$AK_DEBUG_IRC" == "yes" ]
+ then
+ _ak_log_print_log_line_irc "$TS <$prg> [$tp] $msg" >&2
+ fi
else
- echo "$TS" "<$prg>" "[ERROR]" "No message" >> $AK_LOGSFILE
- if [ "$AK_DEBUG" == "yes" ]
+ echo "$TS" "<$prg>" "[ERROR]" "No message" >> $AK_LOGSFILE
+ if [ $AK_DEBUG -eq 5 ]
then
echo "$TS" "<$prg>" "[ERROR]" "No message" >&2
fi
@@ -157,7 +182,7 @@ function _ak_log_message(){
then
echo "$TS" "<$prg>" "[ERROR]" "No type and message" >> $AK_LOGSFILE
fi
- if [ "$AK_DEBUG" == "yes" ]
+ if [ $AK_DEBUG -eq 5 ]
then
echo "$TS" "<$prg>" "[ERROR]" "No type and message" >&2
fi
@@ -168,7 +193,7 @@ function _ak_log_message(){
then
echo "$TS" "<$(basename $0)>" "[ERROR]" "No arguments given" >> $AK_LOGSFILE
fi
- if [ "$AK_DEBUG" == "yes" ]
+ if [ $AK_DEBUG -eq 5 ]
then
echo "$TS" "<$(basename $0)>" "[ERROR]" "No arguments given" >&2
fi