Re: [master 5/6] logging: introduce stderr logger and use it for critical situations in kickstart.py.

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

 



Did you test this with a serial console ?

I've discussed the before with clumens and the reason to
use print is that that does the right thing wrt serial consoles.

Also notice that the cmdline.py InterfaceClass uses print in a lot
of places.

Regards,

Hans


On 02/17/2010 05:53 PM, Ales Kozumplik wrote:
---
  anaconda_log.py |    6 ++++++
  kickstart.py    |   22 +++++++++++-----------
  2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/anaconda_log.py b/anaconda_log.py
index edaf232..6ce8955 100644
--- a/anaconda_log.py
+++ b/anaconda_log.py
@@ -94,6 +94,12 @@ class AnacondaLog:
          self.addFileHandler(sys.stdout, stdoutLogger,
                              fmtStr=STDOUT_FORMAT, minLevel=logging.INFO)

+        # Stderr logger
+        stderrLogger = logging.getLogger("anaconda.stderr")
+        stderrLogger.setLevel(logging.INFO)
+        self.addFileHandler(sys.stderr, stderrLogger,
+                            fmtStr=STDOUT_FORMAT, minLevel=logging.INFO)
+
      # Add a simple handler - file or stream, depending on what we're given.
      def addFileHandler (self, file, addToLogger, minLevel=DEFAULT_TTY_LEVEL,
                          fmtStr=ENTRY_FORMAT,
diff --git a/kickstart.py b/kickstart.py
index 84434b8..26484b7 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -55,7 +55,7 @@ _ = lambda x: gettext.ldgettext("anaconda", x)

  import logging
  log = logging.getLogger("anaconda")
-stdoutLog = logging.getLogger("anaconda.stdout")
+stderrLog = logging.getLogger("anaconda.stderr")
  from anaconda_log import logger, logLevelMap, setHandlersLevel,\
      DEFAULT_TTY_LEVEL

@@ -1169,16 +1169,16 @@ def preScriptPass(anaconda, file):
              anaconda.intf.kickstartErrorWindow("Could not open kickstart file or included file named %s" % e.filename)
              sys.exit(1)
          else:
-            print _("The following error was found while parsing the kickstart "
-                    "configuration file:\n\n%s") % e
+            stderrLog.critical(_("The following error was found while parsing the kickstart "
+                              "configuration file:\n\n%s") % e)
              sys.exit(1)
      except KickstartError, e:
         if anaconda.intf:
             anaconda.intf.kickstartErrorWindow(e.__str__())
             sys.exit(1)
         else:
-            print _("The following error was found while parsing the kickstart "
-                    "configuration file:\n\n%s") % e
+            stderrLog.critical(_("The following error was found while parsing the kickstart "
+                              "configuration file:\n\n%s") % e)
              sys.exit(1)

      # run %pre scripts
@@ -1188,10 +1188,10 @@ def parseKickstart(anaconda, file):
      try:
          file = preprocessKickstart(file)
      except KickstartError, msg:
-        stdoutLog.critical(_("Error processing %%ksappend lines: %s") % msg)
+        stderrLog.critical(_("Error processing %%ksappend lines: %s") % msg)
          sys.exit(1)
      except Exception, e:
-        stdoutLog.critical(_("Unknown error processing %%ksappend lines: %s") % e)
+        stderrLog.critical(_("Unknown error processing %%ksappend lines: %s") % e)
          sys.exit(1)

      handler = AnacondaKSHandler(anaconda)
@@ -1215,16 +1215,16 @@ def parseKickstart(anaconda, file):
              anaconda.intf.kickstartErrorWindow("Could not open kickstart file or included file named %s" % e.filename)
              sys.exit(1)
          else:
-            print _("The following error was found while parsing the kickstart "
-                    "configuration file:\n\n%s") % e
+            stderrLog.critical(_("The following error was found while parsing the kickstart "
+                              "configuration file:\n\n%s") % e)
              sys.exit(1)
      except KickstartError, e:
          if anaconda.intf:
              anaconda.intf.kickstartErrorWindow(e.__str__())
              sys.exit(1)
          else:
-            print _("The following error was found while parsing the kickstart "
-                    "configuration file:\n\n%s") % e
+            stderrLog.critical(_("The following error was found while parsing the kickstart "
+                              "configuration file:\n\n%s") % e)
              sys.exit(1)

      return handler

_______________________________________________
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