python::GBSLogger::GBSLogger Class Reference

List of all members.

Public Member Functions

def __init__
def GetLevelAsChar
def GetLoggerThreshold
def SetLoggerThreshold
def Log

Public Attributes

 FATAL
 ERROR
 WARNING
 INFO
 SYNOPSIS
 DEBUG

Private Attributes

 __loggerThresholdTerminal
 __LoggerThresholdPermanent

Detailed Description

Internal logger - for reporting information about GBS itself

Definition at line 7 of file GBSLogger.py.


Member Function Documentation

def python::GBSLogger::GBSLogger::__init__ (   self  ) 

Definition at line 10 of file GBSLogger.py.

00010                       :
00011         self.FATAL     = 6   # Crash and burn
00012         self.ERROR     = 5   # Something is definitely wrong but can continue
00013         self.WARNING   = 4   # Something is unusual but not definitely wrong 
00014         self.INFO      = 3   # Normal stuff user expects to see
00015         self.SYNOPSIS  = 2   # A bit more detail so user can see a what going on behind the scenes
00016                              #  includes object construction.
00017         self.DEBUG     = 1   # In depth debug level
00018 
00019         self.__loggerThresholdTerminal  = int(GBSConfig.GetConfigValue('LoggerThresholdTerminal'))
00020         self.__LoggerThresholdPermanent = int(GBSConfig.GetConfigValue('LoggerThresholdPermanent'))
00021 
    def GetLevelAsChar(self,level):

def python::GBSLogger::GBSLogger::GetLevelAsChar (   self,
  level 
)

Return supplied level as a single char

Definition at line 22 of file GBSLogger.py.

00022                                   :
00023         """Return supplied level as a single char"""
00024         char = "?"
00025         if level == self.FATAL     : char = "F"
00026         if level == self.ERROR     : char = "E"
00027         if level == self.WARNING   : char = "W"
00028         if level == self.INFO      : char = "I"
00029         if level == self.SYNOPSIS  : char = "S"
00030         if level == self.DEBUG     : char = "D"
00031         return char
00032 
    def GetLoggerThreshold(self,stream = "Terminal"):

def python::GBSLogger::GBSLogger::GetLoggerThreshold (   self,
  stream = "Terminal" 
)

Return the current threshold level for the stream.

Definition at line 33 of file GBSLogger.py.

00033                                                     :
00034         """Return the current threshold level for the stream."""
00035         if stream != "Permanent": return self.__loggerThresholdTerminal 
00036         return self.__LoggerThresholdPermanent
00037      
    def SetLoggerThreshold(self,level,stream = "Terminal"):

def python::GBSLogger::GBSLogger::Log (   self,
  caller,
  level,
  message 
)

Send message to logger streams.

Definition at line 51 of file GBSLogger.py.

00051                                        :
00052         """Send message to logger streams."""
00053         if level >= self.__loggerThresholdTerminal: print message
00054         if level < self.__LoggerThresholdPermanent: return
00055 
00056         # Logging to permanent stream
00057         time_stamp = GBSTimeStamp.GBSTimeStamp()
00058         task_name  = ""
00059         try:
00060             caller_type = caller.GetType()
00061             if caller_type == "GBSLogger": return  
00062             # So long as object type ends Task or Job assume it is one
00063             if re.search(r"Task$",caller_type): task_name = caller.GetName()
00064             if re.search(r"Job$",caller_type):  task_name = caller.GetParent().GetName()
00065         except: pass
00066         log_file = ""
00067         if task_name: log_file = GBSConfig.GetConfigValue('Logger-' + task_name + '-Directory')
00068         if log_file:
00069             log_file += "/gbs_global_" + task_name + "_" + time_stamp[0:10] + ".log"
00070         else:
00071             log_file = GBSConfig.GetConfigValue('LoggerGlobalDirectory')
00072             log_file += "/gbs_global_summary_" + time_stamp[0:10] + ".log"
00073         msg_prefx = time_stamp + " -" + self.GetLevelAsChar(level) + "-"\
00074                     + str(os.getpid()).rjust(7)  + " " + task_name.ljust(20)
00075         # Change any double quote in message to single quote so that we can use 'echo'
00076         message = re.compile(r'"').sub("'",message)
00077         os.system("echo \"%s %s\"  >> %s" % (msg_prefx,message,log_file))
00078         return
00079 
00080 #  Singleton object and access methods
00081 
logger = GBSLogger()

def python::GBSLogger::GBSLogger::SetLoggerThreshold (   self,
  level,
  stream = "Terminal" 
)

Set new level threshold for the stream.

Definition at line 38 of file GBSLogger.py.

00038                                                           :
00039         """Set new level threshold for the stream."""
00040         old_level = self.__loggerThresholdTerminal
00041         if stream != "Permanent":
00042             stream = "Terminal"
00043             if self.__loggerThresholdTerminal == level: return
00044             self.__loggerThresholdTerminal = level
00045         else:
00046             if self.__LoggerThresholdPermanent == level: return
00047             old_level = self.__LoggerThresholdPermanent
00048             self.__LoggerThresholdPermanent = level
00049         print "Changing %s loggerThreshold: %d -> %d" % (stream,old_level,level)
00050 
    def Log(self,caller,level,message) :


Member Data Documentation

python::GBSLogger::GBSLogger::__LoggerThresholdPermanent [private]

Definition at line 20 of file GBSLogger.py.

python::GBSLogger::GBSLogger::__loggerThresholdTerminal [private]

Definition at line 19 of file GBSLogger.py.

python::GBSLogger::GBSLogger::DEBUG

Definition at line 17 of file GBSLogger.py.

python::GBSLogger::GBSLogger::ERROR

Definition at line 12 of file GBSLogger.py.

python::GBSLogger::GBSLogger::FATAL

Definition at line 11 of file GBSLogger.py.

python::GBSLogger::GBSLogger::INFO

Definition at line 14 of file GBSLogger.py.

python::GBSLogger::GBSLogger::SYNOPSIS

Definition at line 15 of file GBSLogger.py.

python::GBSLogger::GBSLogger::WARNING

Definition at line 13 of file GBSLogger.py.


The documentation for this class was generated from the following file:
Generated on Fri Mar 5 09:25:41 2010 for gbs by  doxygen 1.4.7