2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-08-15 15:50:22 +00:00

try various log method according to the different version of logger

This commit is contained in:
immarvin
2015-07-10 04:20:36 -04:00
parent 1bf53a2a84
commit 4074b4f4e7

View File

@@ -7,9 +7,21 @@ declare -F msgutil_r &>/dev/null || function msgutil_r {
if [ -z "$msgtype" ]; then
msgtype="debug"
fi
logger -n $logserver -t xcat -p local4.$msgtype "$msgstr"
if [ -n "logserver" ];then
logger -n $logserver -t xcat -p local4.$msgtype "$msgstr"
if [ "$?" != "0" ];then
exec 3<>/dev/udp/$logserver/514 >/dev/null 2>&1;logger -s -t xcat -p local4.$msgtype "$msgstr" 1>&3 2>&1
if [ "$?" != "0" ];then
logger -s -t xcat -p local4.$msgtype "$msgstr" 2>&1|nc $logserver 514 >/dev/null 2>&1
if [ "$?" != "0" ];then
logger -t xcat -p local4.$msgtype "$msgstr"
fi
fi
fi
else
logger -t xcat -p local4.$msgtype "$msgstr"
fi
if [ -n "$logfile" ]; then
local logdir="$(dirname $logfile)"
if [ ! -d "$logdir" ]; then
@@ -17,13 +29,11 @@ declare -F msgutil_r &>/dev/null || function msgutil_r {
touch "$logfile"
fi
# echo "$msgstr" | tee -a $logfile
#else
echo "$msgstr" >> $logfile
fi
}
declare -F msgutil &>/dev/null || function msgutil {
msgutil_r "localhost" "$@"
msgutil_r "" "$@"
}