Re: [master 1/2] anaconda, storage and yum: log to tty3 in the same format as we log into tty4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ack.

On 01/29/2010 01:37 PM, Ales Kozumplik wrote:
---
  anaconda               |    3 ++-
  anaconda_log.py        |    7 +++++--
  storage/storage_log.py |    4 +++-
  yuminstall.py          |    3 ++-
  4 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/anaconda b/anaconda
index 6807020..ab8b088 100755
--- a/anaconda
+++ b/anaconda
@@ -616,7 +616,8 @@ if __name__ == "__main__":
      anaconda.platform = platform.getPlatform(anaconda)

      if not iutil.isS390() and os.access("/dev/tty3", os.W_OK):
-        anaconda_log.logger.addFileHandler ("/dev/tty3", log)
+        anaconda_log.logger.addFileHandler("/dev/tty3", log,
+                                           fmtStr=anaconda_log.DEFAULT_TTY_FORMAT)

      warnings.showwarning = AnacondaShowWarning

diff --git a/anaconda_log.py b/anaconda_log.py
index 9345323..40d3979 100644
--- a/anaconda_log.py
+++ b/anaconda_log.py
@@ -28,7 +28,8 @@ from logging.handlers import SysLogHandler, SYSLOG_UDP_PORT
  import types

  DEFAULT_LEVEL = logging.INFO
-DEFAULT_ENTRY_FORMAT = "%(asctime)s,%(msecs)03d %(levelname)-8s: %(message)s"
+DEFAULT_ENTRY_FORMAT = "%(asctime)s,%(msecs)03d %(levelname)s %(name)s: %(message)s"
+DEFAULT_TTY_FORMAT = "%(levelname)s %(name)s: %(message)s"
  DEFAULT_DATE_FORMAT = "%H:%M:%S"

  MAIN_LOG_FILE = "/tmp/anaconda.log"
@@ -57,8 +58,10 @@ class AnacondaSyslogHandler(SysLogHandler):
          SysLogHandler.__init__(self, address, facility)

      def emit(self, record):
-        record.msg = '%s: %s' %(self.tag, record.msg)
+        original_msg = record.msg
+        record.msg = '%s: %s' %(self.tag, original_msg)
          SysLogHandler.emit(self, record)
+        record.msg = original_msg

  class AnacondaLog:
      def __init__ (self, minLevel=DEFAULT_LEVEL):
diff --git a/storage/storage_log.py b/storage/storage_log.py
index 006c781..b852270 100644
--- a/storage/storage_log.py
+++ b/storage/storage_log.py
@@ -25,5 +25,7 @@ def log_method_call(d, *args, **kwargs):
  logger = logging.getLogger("storage")
  logger.setLevel(logging.DEBUG)
  anaconda_log.logger.addFileHandler("/tmp/storage.log", logger, logging.DEBUG)
-anaconda_log.logger.addFileHandler("/dev/tty3", logger, logging.DEBUG)
+anaconda_log.logger.addFileHandler("/dev/tty3", logger,
+                                   anaconda_log.DEFAULT_LEVEL,
+                                   anaconda_log.DEFAULT_TTY_FORMAT)
  anaconda_log.logger.forwardToSyslog(logger)
diff --git a/yuminstall.py b/yuminstall.py
index c57d360..8003902 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -619,7 +619,8 @@ class AnacondaYum(YumSorter):
          file_handler.setFormatter(file_formatter)

          tty3_handler = logging.FileHandler("/dev/tty3")
-        tty3_formatter = logging.Formatter("%(asctime)s %(levelname)-8s: %(name)s: %(message)s", "%H:%M:%S")
+        tty3_formatter = logging.Formatter(anaconda_log.DEFAULT_TTY_FORMAT,
+                                           anaconda_log.DEFAULT_DATE_FORMAT)
          tty3_handler.setFormatter(tty3_formatter)

          verbose = logging.getLogger("yum.verbose")

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux