[rhel7-branch 18/29] Remove logging to tty3 and tty5 (#1073336)

bcl installerbot-noreply at redhat.com
Tue Jun 2 00:31:19 UTC 2015


From: "Brian C. Lane" <bcl at redhat.com>

tmux handles tailing the relevant logs in other windows, there is no
need to be writing directly to a tty any longer. It also interferes with
the host system when running anaconda using --image or --dirinstall from
the cmdline.

Resolves: rhbz#1073336

(cherry picked from commit 6898a7c3baba7c062e9f70acbdc98011aa8d7cf6)

Related: rhbz#1196721
---
 anaconda                   |  2 +-
 pyanaconda/anaconda_log.py | 19 +++----------------
 pyanaconda/kickstart.py    |  7 +++----
 pyanaconda/network.py      |  9 ++-------
 4 files changed, 9 insertions(+), 28 deletions(-)

diff --git a/anaconda b/anaconda
index ac9a17c..3b9e71d 100755
--- a/anaconda
+++ b/anaconda
@@ -567,7 +567,7 @@ def setupLoggingFromOpts(options):
     if options.loglevel and options.loglevel in anaconda_log.logLevelMap:
         log.info("Switching logging level to %s", options.loglevel)
         level = anaconda_log.logLevelMap[options.loglevel]
-        anaconda_log.logger.tty_loglevel = level
+        anaconda_log.logger.loglevel = level
         anaconda_log.setHandlersLevel(log, level)
         storage_log = logging.getLogger("storage")
         anaconda_log.setHandlersLevel(storage_log, level)
diff --git a/pyanaconda/anaconda_log.py b/pyanaconda/anaconda_log.py
index 5c7b78b..1cdf0da 100644
--- a/pyanaconda/anaconda_log.py
+++ b/pyanaconda/anaconda_log.py
@@ -32,16 +32,13 @@
 from pyanaconda.flags import flags
 from pyanaconda.constants import LOGLVL_LOCK
 
-DEFAULT_TTY_LEVEL = logging.INFO
+DEFAULT_LEVEL = logging.INFO
 ENTRY_FORMAT = "%(asctime)s,%(msecs)03d %(levelname)s %(name)s: %(message)s"
-TTY_FORMAT = "%(levelname)s %(name)s: %(message)s"
 STDOUT_FORMAT = "%(asctime)s %(message)s"
 DATE_FORMAT = "%H:%M:%S"
 
 MAIN_LOG_FILE = "/tmp/anaconda.log"
-MAIN_LOG_TTY = "/dev/tty3"
 PROGRAM_LOG_FILE = "/tmp/program.log"
-PROGRAM_LOG_TTY = "/dev/tty5"
 STORAGE_LOG_FILE = "/tmp/storage.log"
 PACKAGING_LOG_FILE = "/tmp/packaging.log"
 SENSITIVE_INFO_LOG_FILE = "/tmp/sensitive-info.log"
@@ -94,7 +91,7 @@ class AnacondaLog:
     VIRTIO_PORT = "/dev/virtio-ports/org.fedoraproject.anaconda.log.0"
 
     def __init__ (self):
-        self.tty_loglevel = DEFAULT_TTY_LEVEL
+        self.loglevel = DEFAULT_LEVEL
         self.remote_syslog = None
         # Rename the loglevels so they are the same as in syslog.
         logging.addLevelName(logging.WARNING, "WARN")
@@ -117,22 +114,12 @@ def __init__ (self):
         for logr in [self.anaconda_logger, storage_logger]:
             logr.setLevel(logging.DEBUG)
             self.forwardToSyslog(logr)
-            # Logging of basic stuff and storage to tty3.
-            # XXX Use os.uname here since it's too early to be importing the
-            #     storage module.
-            if not os.uname()[4].startswith('s390') and os.access(MAIN_LOG_TTY, os.W_OK):
-                self.addFileHandler(MAIN_LOG_TTY, logr,
-                                    fmtStr=TTY_FORMAT,
-                                    autoLevel=True)
 
         # External program output log
         program_logger = logging.getLogger("program")
         program_logger.setLevel(logging.DEBUG)
         self.addFileHandler(PROGRAM_LOG_FILE, program_logger,
                             minLevel=logging.DEBUG)
-        self.addFileHandler(PROGRAM_LOG_TTY, program_logger,
-                            fmtStr=TTY_FORMAT,
-                            autoLevel=True)
         self.forwardToSyslog(program_logger)
 
         # Create the packaging logger.
@@ -175,7 +162,7 @@ def __init__ (self):
                             fmtStr=STDOUT_FORMAT, minLevel=logging.INFO)
 
     # Add a simple handler - file or stream, depending on what we're given.
-    def addFileHandler (self, dest, addToLogger, minLevel=DEFAULT_TTY_LEVEL,
+    def addFileHandler (self, dest, addToLogger, minLevel=DEFAULT_LEVEL,
                         fmtStr=ENTRY_FORMAT,
                         autoLevel=False):
         try:
diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
index 80199e6..de80997 100644
--- a/pyanaconda/kickstart.py
+++ b/pyanaconda/kickstart.py
@@ -76,8 +76,7 @@
 stderrLog = logging.getLogger("anaconda.stderr")
 storage_log = logging.getLogger("blivet")
 stdoutLog = logging.getLogger("anaconda.stdout")
-from pyanaconda.anaconda_log import logger, logLevelMap, setHandlersLevel,\
-    DEFAULT_TTY_LEVEL
+from pyanaconda.anaconda_log import logger, logLevelMap, setHandlersLevel, DEFAULT_LEVEL
 
 class AnacondaKSScript(KSScript):
     """ Execute a kickstart script
@@ -1047,10 +1046,10 @@ def execute(self, storage, ksdata, instClass):
 
 class Logging(commands.logging.FC6_Logging):
     def execute(self, *args):
-        if logger.tty_loglevel == DEFAULT_TTY_LEVEL:
+        if logger.loglevel == DEFAULT_LEVEL:
             # not set from the command line
             level = logLevelMap[self.level]
-            logger.tty_loglevel = level
+            logger.loglevel = level
             setHandlersLevel(log, level)
             setHandlersLevel(storage_log, level)
 
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index fb6f3dd..d0e9f99 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -71,11 +71,6 @@ def setup_ifcfg_log():
     logger = logging.getLogger("ifcfg")
     logger.setLevel(logging.DEBUG)
     anaconda_log.logger.addFileHandler(ifcfgLogFile, logger, logging.DEBUG)
-    if os.access("/dev/tty3", os.W_OK):
-        anaconda_log.logger.addFileHandler("/dev/tty3", logger,
-                                           anaconda_log.DEFAULT_TTY_LEVEL,
-                                           anaconda_log.TTY_FORMAT,
-                                           autoLevel=True)
     anaconda_log.logger.forwardToSyslog(logger)
 
     ifcfglog = logging.getLogger("ifcfg")
@@ -140,9 +135,9 @@ def get_default_device_ip():
     if devname:
         try:
             ip = nm.nm_device_ip_addresses(devname, version=4)[0]
-        except Exception as e:
+        except (dbus.DBusException, ValueError) as e:
             log.warning("Got an exception trying to get the ip addr "
-                        "of %s: %s" % (devname, e))
+                        "of %s: %s", devname, e)
     return ip
 
 def netmask2prefix(netmask):


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/afc029ce256366bded1b66e6f82597ee3f3d3ef4


More information about the anaconda-patches mailing list