Send all the logs to a remote host:port instead of modifying the rsyslog configuration of the host. This will be useful when running anaconda from the cmdline or via livemedia-creator
All that's required on the receiving side is netcat listening to the port. --- anaconda | 14 ++++++++++++-- pyanaconda/anaconda_log.py | 11 ++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/anaconda b/anaconda index 4ded503..d97b682 100755 --- a/anaconda +++ b/anaconda @@ -309,6 +309,7 @@ def parseArguments(argv=None, boot_cmdline=None): # Obvious ap.add_argument("--loglevel", metavar="LEVEL", help=help_parser.help_text("loglevel")) ap.add_argument("--syslog", metavar="HOST[:PORT]", help=help_parser.help_text("syslog")) + ap.add_argument("--remotelog", metavar="HOST:PORT", help=help_parser.help_text("remotelog"))
from pykickstart.constants import SELINUX_DISABLED, SELINUX_ENFORCING from pyanaconda.constants import SELINUX_DEFAULT @@ -409,8 +410,17 @@ def setupLoggingFromOpts(options): packaging_log = logging.getLogger("packaging") anaconda_log.setHandlersLevel(packaging_log, level)
- if options.syslog: - anaconda_log.logger.updateRemote(options.syslog) + if can_touch_runtime_system("syslog setup"): + if options.syslog: + anaconda_log.logger.updateRemote(options.syslog) + + if options.remotelog: + try: + host, port = options.remotelog.split(":", 1) + port = int(port) + anaconda_log.logger.setup_remotelog(host, port) + except ValueError: + log.error("Could not setup remotelog with %s", options.remotelog)
def gtk_warning(title, reason): from gi.repository import Gtk diff --git a/pyanaconda/anaconda_log.py b/pyanaconda/anaconda_log.py index 498d64a..b5e525c 100644 --- a/pyanaconda/anaconda_log.py +++ b/pyanaconda/anaconda_log.py @@ -23,7 +23,7 @@ #
import logging -from logging.handlers import SysLogHandler, SYSLOG_UDP_PORT +from logging.handlers import SysLogHandler, SocketHandler, SYSLOG_UDP_PORT import os import sys import types @@ -86,6 +86,10 @@ class AnacondaSyslogHandler(SysLogHandler): """Map the priority level to a syslog level """ return self.levelMap.get(level, SysLogHandler.mapPriority(self, level))
+class AnacondaSocketHandler(SocketHandler): + def makePickle(self, record): + return ENTRY_FORMAT % record.__dict__ + "\n" + class AnacondaLog: SYSLOG_CFGFILE = "/etc/rsyslog.conf" VIRTIO_PORT = "/dev/virtio-ports/org.fedoraproject.anaconda.log.0" @@ -203,6 +207,11 @@ class AnacondaLog: self.anaconda_logger.warning("%s", warnings.formatwarning( message, category, filename, lineno, line))
+ def setup_remotelog(self, host, port): + remotelog = AnacondaSocketHandler(host, port) + remotelog.setLevel(logging.DEBUG) + logging.getLogger().addHandler(remotelog) + def restartSyslog(self): # Import here instead of at the module level to avoid an import loop from pyanaconda.iutil import execWithRedirect
On Fri, 2015-01-09 at 09:49 -0800, Brian C. Lane wrote:
Send all the logs to a remote host:port instead of modifying the rsyslog configuration of the host. This will be useful when running anaconda from the cmdline or via livemedia-creator
All that's required on the receiving side is netcat listening to the port.
Neat and useful, ACK.
anaconda-patches@lists.fedorahosted.org