[master][PATCH] Grab journalctl logs if there is no /tmp/syslog
Vratislav Podzimek
vpodzime at redhat.com
Fri Sep 27 18:06:21 UTC 2013
If we have our rsyslogd instance running and hooked to /tmp/syslog, we can
simply grab logs from there. Otherwise we need to grab journalctl's output and
filter it to omit our own log messages from there because there is no
/var/log/messages anymore.
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/exception.py | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/exception.py b/pyanaconda/exception.py
index 7c80ca7..2296af4 100644
--- a/pyanaconda/exception.py
+++ b/pyanaconda/exception.py
@@ -32,6 +32,7 @@ import shutil
import signal
import time
import kickstart
+import re
import blivet.errors
from pyanaconda.ui.communication import hubQ
from pyanaconda.constants import ROOT_PATH, THREAD_EXCEPTION_HANDLING_TEST
@@ -195,9 +196,8 @@ def initExceptionHandling(anaconda):
"/tmp/program.log", "/tmp/storage.log", "/tmp/ifcfg.log",
"/tmp/yum.log", ROOT_PATH + "/root/install.log",
"/proc/cmdline" ]
- if flags.flags.livecdInstall:
- fileList.extend(["/var/log/messages"])
- else:
+
+ if os.path.exists("/tmp/syslog"):
fileList.extend(["/tmp/syslog"])
if anaconda.opts and anaconda.opts.ksfile:
@@ -230,6 +230,11 @@ def initExceptionHandling(anaconda):
attchmnt_only=True)
conf.register_callback("type", lambda: "anaconda", attchmnt_only=True)
+ if "/tmp/syslog" not in fileList:
+ # no syslog, grab output from journalctl and put it also to the
+ # anaconda-tb file
+ conf.register_callback("journalctl", journalctl_callback, attchmnt_only=False)
+
handler = AnacondaExceptionHandler(conf, anaconda.intf.meh_interface,
ReverseExceptionDump, anaconda.intf.tty_num)
handler.install(anaconda)
@@ -246,6 +251,20 @@ def nmcli_dev_list_callback():
return iutil.execWithCapture("nmcli", ["device", "show"])
+def journalctl_callback():
+ """Callback to get logs from journalctl."""
+
+ # regex to filter log messages from anaconda's process (we have that in our
+ # logs)
+ anaconda_log_line = re.compile(r"\[%d\]:" % os.getpid())
+ ret = ""
+ for line in iutil.execReadlines("journalctl", []):
+ if anaconda_log_line.search(line) is None:
+ # not an anaconda's message
+ ret += line + "\n"
+
+ return ret
+
def test_exception_handling():
"""
Function that can be used for testing exception handling in anaconda. It
--
1.7.11.7
More information about the anaconda-patches
mailing list