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 > Redhat > Fedora Games

 
 
LinkBack Thread Tools
 
Old 12-01-2009, 12:15 PM
Ales Kozumplik
 
Default Log storage in the same format as the main anaconda log (a part of #524980)

:: the entry format and date format is standardized: do not show date but always show miliseconds
:: includes a cleanup in the storage/storage_log.py code to use AnacondaLog
---
anaconda_log.py | 8 +++++---
storage/storage_log.py | 16 +++-------------
2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/anaconda_log.py b/anaconda_log.py
index 99ae58e..78ffbed 100644
--- a/anaconda_log.py
+++ b/anaconda_log.py
@@ -27,6 +27,8 @@ import logging
from logging.handlers import SysLogHandler, SYSLOG_UDP_PORT

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

logFile = "/tmp/anaconda.log"

@@ -72,15 +74,15 @@ class AnacondaLog:

# Add a simple handler - file or stream, depending on what we're given.
def addFileHandler (self, file, addToLogger, minLevel=DEFAULT_LEVEL,
- fmtStr="%(asctime)s %(levelname)-8s: %(message)s",
+ fmtStr=DEFAULT_ENTRY_FORMAT,
autoSetLevel=True):
- if type (file) == type ("string"):
+ if isinstance(file, str):
logfileHandler = logging.FileHandler(file)
else:
logfileHandler = logging.StreamHandler(file)

logfileHandler.setLevel(minLevel)
- logfileHandler.setFormatter (logging.Formatter (fmtStr, "%H:%M:%S"))
+ logfileHandler.setFormatter(logging.Formatter(fmtS tr, DEFAULT_DATE_FORMAT))
addToLogger.addHandler(logfileHandler, autoSetLevel=autoSetLevel)

# Add another logger to the hierarchy. For best results, make sure
diff --git a/storage/storage_log.py b/storage/storage_log.py
index a771154..66a101e 100644
--- a/storage/storage_log.py
+++ b/storage/storage_log.py
@@ -1,17 +1,7 @@
import logging
-
-
-#handler = logging.StreamHandler()
-file_handler = logging.FileHandler("/tmp/storage.log")
-formatter = logging.Formatter("[%(asctime)s] %(levelname)8s: %(message)s")
-file_handler.setFormatter(formatter)
-
-tty3_handler = logging.FileHandler("/dev/tty3")
-tty3_handler.setFormatter(formatter)
+import anaconda_log

logger = logging.getLogger("storage")
-logger.addHandler(file_handler)
-logger.addHandler(tty3_handler)
logger.setLevel(logging.DEBUG)
-
-
+anaconda_log.logger.addFileHandler("/tmp/storage.log", logger, logging.DEBUG)
+anaconda_log.logger.addFileHandler("/dev/tty3", logger, logging.DEBUG)
--
1.6.2.5

_______________________________________________
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 08:45 PM.

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