dracut: use sysloglvl for systemd-cat logging

master
Harald Hoyer 2013-07-19 09:46:00 +02:00
parent bbaa0d5917
commit 6b1e7a6ca4
2 changed files with 11 additions and 12 deletions

View File

@ -138,6 +138,9 @@ dlog_init() {
errmsg="'$logfile' is not a writable file"
fi
fi
fi

if (( $sysloglvl > 0 )); then
if type -P systemd-cat &>/dev/null && (( $UID == 0 )) ; then
readonly _dlogdir="$(mktemp --tmpdir="$TMPDIR/" -d -t dracut-log.XXXXXX)"
readonly _systemdcatfile="$_dlogdir/systemd-cat"
@ -145,12 +148,7 @@ dlog_init() {
readonly _dlogfd=15
systemd-cat -t 'dracut' <"$_systemdcatfile" &
exec 15>"$_systemdcatfile"
fi
fi

if (( $sysloglvl > 0 )); then
if ! [ -S /dev/log -a -w /dev/log ] || ! command -v logger >/dev/null
then
elif ! [ -S /dev/log -a -w /dev/log ] || ! command -v logger >/dev/null; then
# We cannot log to syslog, so turn this facility off.
sysloglvl=0
ret=1
@ -320,18 +318,19 @@ _do_dlog() {
local lmsg="$lvlc: $*"

(( $lvl <= $stdloglvl )) && echo "$msg" >&2

if (( $lvl <= $sysloglvl )); then
logger -t "dracut[$$]" -p $(_lvl2syspri $lvl) "$msg"
if [[ "$_dlogfd" ]]; then
echo "<$(_dlvl2syslvl $lvl)>$msg" >&$_dlogfd
else
logger -t "dracut[$$]" -p $(_lvl2syspri $lvl) "$msg"
fi
fi

if (( $lvl <= $fileloglvl )) && [[ -w "$logfile" ]] && [[ -f "$logfile" ]]; then
echo "$lmsg" >>"$logfile"
fi

if (( $lvl <= $fileloglvl )) && [[ "$_dlogfd" ]]; then
echo "<$(_dlvl2syslvl $lvl)>$msg" >&$_dlogfd
fi

(( $lvl <= $kmsgloglvl )) && \
echo "<$(_dlvl2syslvl $lvl)>dracut[$$] $msg" >/dev/kmsg
}

View File

@ -5,7 +5,7 @@ i18n_vars="/etc/sysconfig/keyboard:KEYTABLE-KEYMAP /etc/sysconfig/i18n:SYSFONT-F
i18n_default_font="latarcyrheb-sun16"
omit_drivers+=' .*/fs/ocfs/.* i2o_scsi'
stdloglvl=3
fileloglvl=5
sysloglvl=5
install_items+=" vi /etc/virc ps grep cat rm "
prefix="/"
systemdutildir=/usr/lib/systemd