dracut: use sysloglvl for systemd-cat logging
authorHarald Hoyer <harald@redhat.com>
Fri, 19 Jul 2013 07:46:00 +0000 (09:46 +0200)
committerHarald Hoyer <harald@redhat.com>
Fri, 19 Jul 2013 07:46:00 +0000 (09:46 +0200)
dracut-logger.sh
dracut.conf.d/fedora.conf.example

index 2e3c1ed..74a8a1b 100755 (executable)
@@ -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
 }
index fd94e83..c10dca3 100644 (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