if [ -z "$fileloglvl" ]; then
[ -w "$logfile" ] && fileloglvl=4 || fileloglvl=0
- elif [ $fileloglvl -gt 0 ]; then
+ elif (( $fileloglvl >= 0 )); then
__oldumask=$(umask)
umask 0377
! [ -e "$logfile" ] && >"$logfile"
fi
fi
- if [ $sysloglvl -gt 0 ]; then
+ if (( $sysloglvl >= 0 )); then
if ! [ -S /dev/log -a -w /dev/log ] || ! command -v logger >/dev/null
then
# We cannot log to syslog, so turn this facility off.
fi
fi
- if [ $sysloglvl -gt 0 -o $kmsgloglvl -gt 0 ]; then
+ if (($sysloglvl >= 0)) || (($kmsgloglvl >= 0 )); then
if [ -n "$dracutbasedir" ]; then
readonly syslogfacility=user
else
local lvl; local maxloglvl_l=0
for lvl in $stdloglvl $sysloglvl $fileloglvl $kmsgloglvl; do
- [ $lvl -gt $maxloglvl_l ] && maxloglvl_l=$lvl
+ (( $lvl > $maxloglvl_l )) && maxloglvl_l=$lvl
done
readonly maxloglvl=$maxloglvl_l
export maxloglvl
local lvlc=$(_lvl2char "$lvl") || return 0
local msg="$lvlc: $*"
- [ $lvl -le $stdloglvl ] && echo "$msg" >&2
- if [ $lvl -le $sysloglvl ]; then
+ (( $lvl <= $stdloglvl )) && echo "$msg" >&2
+ if (( $lvl <= $sysloglvl )); then
logger -t "dracut[$$]" -p $(_lvl2syspri $lvl) "$msg"
fi
- if [ $lvl -le $fileloglvl -a -w "$logfile" -a -f "$logfile" ]; then
+ if (( $lvl <= $fileloglvl )) && [[ -w "$logfile" ]] && [[ -f "$logfile" ]]; then
echo "$msg" >>"$logfile"
fi
- [ $lvl -le $kmsgloglvl ] && \
+ (( $lvl <= $kmsgloglvl )) && \
echo "<$(_dlvl2syslvl $lvl)>dracut[$$] $msg" >/dev/kmsg
}
# echo "This is a warning" | dwarn
dlog() {
[ -z "$maxloglvl" ] && return 0
- [ $1 -le $maxloglvl ] || return 0
+ (( $1 <= $maxloglvl )) || return 0
- if [ $# -gt 1 ]; then
+ if (( $# > 1 )); then
_do_dlog "$@"
else
while read line; do