FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian Kernel

 
 
LinkBack Thread Tools
 
Old 02-17-2010, 03:53 PM
Ales Kozumplik
 
Default logging: introduce stderr logger and use it for critical situations in kickstart.py.

---
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:

%s") % e
+ stderrLog.critical(_("The following error was found while parsing the kickstart "
+ "configuration file:

%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:

%s") % e
+ stderrLog.critical(_("The following error was found while parsing the kickstart "
+ "configuration file:

%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:

%s") % e
+ stderrLog.critical(_("The following error was found while parsing the kickstart "
+ "configuration file:

%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:

%s") % e
+ stderrLog.critical(_("The following error was found while parsing the kickstart "
+ "configuration file:

%s") % e)
sys.exit(1)

return handler
--
1.6.6

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

Thread Tools




All times are GMT. The time now is 04:40 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org