[master/rhel7] Remove logging to tty3 and tty5 (#1073336)

Vratislav Podzimek vpodzime at redhat.com
Mon Aug 25 13:45:22 UTC 2014


On Thu, 2014-08-21 at 17:51 -0700, Brian C. Lane wrote:
> 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
> ---
>  anaconda                   |  2 +-
>  pyanaconda/anaconda_log.py | 19 +++----------------
>  pyanaconda/isys/log.c      | 20 +-------------------
>  pyanaconda/isys/log.h      |  1 -
>  pyanaconda/kickstart.py    |  6 +++---
>  pyanaconda/network.py      |  5 -----
>  6 files changed, 8 insertions(+), 45 deletions(-)
> 
> diff --git a/anaconda b/anaconda
> index ffce0f0..edaf097 100755
> --- a/anaconda
> +++ b/anaconda
> @@ -348,7 +348,7 @@ def setupEnvironment():
>  def setupLoggingFromOpts(options):
>      if options.loglevel and anaconda_log.logLevelMap.has_key(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 e2d6fa5..4f678d8 100644
> --- a/pyanaconda/anaconda_log.py
> +++ b/pyanaconda/anaconda_log.py
> @@ -31,16 +31,13 @@ import warnings
>  
>  from pyanaconda.flags import flags
>  
> -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"
>  ANACONDA_SYSLOG_FACILITY = SysLogHandler.LOG_LOCAL1
> @@ -80,7 +77,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")
> @@ -102,22 +99,12 @@ class AnacondaLog:
>          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.
> @@ -151,7 +138,7 @@ class AnacondaLog:
>                              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/isys/log.c b/pyanaconda/isys/log.c
> index 9c9d5bb..aa285dc 100644
> --- a/pyanaconda/isys/log.c
> +++ b/pyanaconda/isys/log.c
> @@ -34,10 +34,8 @@
>  
>  #include "log.h"
>  
> -static FILE * main_log_tty = NULL;
>  static FILE * main_log_file = NULL;
>  static FILE * program_log_file = NULL;
> -static loglevel_t minLevel = INFO;
>  static const char * main_tag = "anaconda";
>  static const char * program_tag = "program";
>  static const int syslog_facility = LOG_LOCAL1;
> @@ -104,12 +102,9 @@ static void retagSyslog(const char* new_tag)
>  }
>  
>  void logMessageV(enum logger_t logger, loglevel_t level, const char * s, va_list ap) {
> -    FILE *log_tty = main_log_tty;
>      FILE *log_file = main_log_file;
>      const char *tag = main_tag;
>      if (logger == PROGRAM_LOG) {
> -        /* tty output is done directly for programs */
> -        log_tty = NULL;
>          log_file = program_log_file;
>          tag = program_tag;
>          /* close and reopen syslog so we get the tagging right */
> @@ -122,12 +117,7 @@ void logMessageV(enum logger_t logger, loglevel_t level, const char * s, va_list
>      vsyslog(mapLogLevel(level), s, apc);
>      va_end(apc);
>  
> -    /* Only log to the screen things that are above the minimum level. */
> -    if (main_log_tty && level >= minLevel && log_tty) {
> -        printLogMessage(level, tag, log_tty, s, ap);
> -    }
> -
> -    /* But log everything to the file. */
> +    /* Log everything to the file. */
>      if (main_log_file) {
>          printLogMessage(level, tag, log_file, s, ap);
>      }
> @@ -145,7 +135,6 @@ void logMessage(loglevel_t level, const char * s, ...) {
>      va_end(args);
>  }
>  
> -int tty_logfd = -1;
>  int file_logfd = -1;
>  
>  void openLog() {
> @@ -154,16 +143,9 @@ void openLog() {
>      openlog(main_tag, 0, syslog_facility);
>  
>      int flags;
> -    main_log_tty = fopen("/dev/tty3", "a");
>      main_log_file = fopen("/tmp/anaconda.log", "a");
>      program_log_file = fopen("/tmp/program.log", "a");
>  
> -    if (main_log_tty) {
> -        tty_logfd = fileno(main_log_tty);
> -        flags = fcntl(tty_logfd, F_GETFD, 0) | FD_CLOEXEC;
> -        fcntl(tty_logfd, F_SETFD, flags);
> -    }
> -
>      if (main_log_file) {
>          file_logfd = fileno(main_log_file);
>          flags = fcntl(file_logfd, F_GETFD, 0) | FD_CLOEXEC;
> diff --git a/pyanaconda/isys/log.h b/pyanaconda/isys/log.h
> index f095f44..8e050a9 100644
> --- a/pyanaconda/isys/log.h
> +++ b/pyanaconda/isys/log.h
> @@ -42,7 +42,6 @@ void logMessage(loglevel_t level, const char * s, ...)
>      __attribute__ ((format (printf, 2, 3)));
>  void openLog();
>  
> -extern int tty_logfd;
>  extern int file_logfd;
>  
>  #endif /* _LOG_H_ */
> diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
> index 977d9a0..a210a22 100644
> --- a/pyanaconda/kickstart.py
> +++ b/pyanaconda/kickstart.py
> @@ -73,7 +73,7 @@ log = logging.getLogger("anaconda")
>  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
> @@ -920,10 +920,10 @@ class LogVolData(commands.logvol.F20_LogVolData):
>  
>  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 144548d..f0b22bf 100644
> --- a/pyanaconda/network.py
> +++ b/pyanaconda/network.py
> @@ -70,11 +70,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")
A lot of ugly stuff going away, ACK!

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list