示例#1
0
文件: EDLogging.py 项目: kif/edna
 def __init__(self, _strLoggerName="EDVerbose"):
     EDObject.__init__(self)
     if _strLoggerName == "PyLogging":
         self.edLogging = EDLoggingPyLogging()
     else:
         self.edLogging = EDLoggingVerbose()
     self.__messages = []
示例#2
0
class EDLogging(EDObject):
    """
    This class loads one of the EDNA loggers: EDLoggingVerbose, EDLoggingClass
    """
    def __init__(self, _strLoggerName="EDVerbose"):
        EDObject.__init__(self)
        if _strLoggerName == "PyLogging":
            self.edLogging = EDLoggingPyLogging()
        else:
            self.edLogging = EDLoggingVerbose()

    def setLogLevel(self, _logLevel):
        self.edLogging.setLogLevel(_logLevel)

    def setAllLogLevels(self, _logLevel):
        self.edLogging.setAllLogLevels(_logLevel)

    def setTestOn(self):
        """
        turn on the test mode: all assertions become verbose (->screen) 
        """
        self.edLogging.setTestOn()

    def setTestOff(self):
        """
        turn off the test mode: all assertions become silent (->screen) 
        """
        self.edLogging.setTestOff()

    def setVerboseOn(self):
        """
        This method turns on verbose logging to standard output (stdout)
        """
        self.edLogging.setVerboseOn()

    def setVerboseOff(self):
        """
        This method turns off verbose logging to standard output (stdout)
        """
        self.edLogging.setVerboseOff()

    def setVerboseDebugOn(self):
        """
        This method turns on debug messages to standard output and log file
        """
        self.edLogging.setVerboseDebugOn()

    def setVerboseDebugOff(self):
        """
        This method turns off debug messages to standard output and log file
        """
        self.edLogging.setVerboseDebugOff()

    def isVerboseDebug(self):
        """
        This method returns the current status of debugging
        
        @return: if debug output to standard output and log file is enabled.
        @type: boolean
        """
        return self.edLogging.isVerboseDebug()

    def log(self, _strMessage=""):
        """
        This method writes a message only to the log file.
        
        @param _strMessage: The string to be written to the log file
        @type _strMessage: python string
        """
        self.edLogging.log(_strMessage)

    def screen(self, _strMessage=""):
        """
        This method writes a message to standard output and to the log file.
        
        @param _strMessage: The string to be written to the log file
        @type _strMessage: python string
        """
        self.edLogging.screen(_strMessage)

    def DEBUG(self, _strDebugMessage=""):
        """
        This method writes a debug message to standard output and to the log file
        if debugging is enabled. The message will be written with the prefix [DEBUG]
        
        @param _strDebugMessage: The debug message to be written to standard output and log file
        @type _strDebugMessage: python string
        """
        self.edLogging.DEBUG(_strDebugMessage)

    def unitTest(self, _strMessage=""):
        """
        This method is meant to be used by the testing framework. The message will be written 
        to standard output and the log file with the prefix [UnitTest]
        
        @param _strMessage: The message to be written to standard output and log file
        @type _strMessage: python string
        """
        self.edLogging.unitTest(_strMessage)

    def ERROR(self, _strMessage=""):
        """
        This method writes a message to standard error and the log file with the prefix [ERROR].
        
        @param _strMessage: The error message to be written to standard output and log file
        @type _strMessage: python string
        """
        self.edLogging.ERROR(_strMessage)

    def error(self, _strMessage=""):
        """
        This method writes a message to standard error and the log file with the prefix [ERROR].
        
        @param _strMessage: The error message to be written to standard output and log file
        @type _strMessage: python string
        """
        self.edLogging.error(_strMessage)

    def WARNING(self, _strMessage=""):
        """
        This method writes a warning message to standard output and the log file with the prefix [Warning].
        
        @param _strMessage: The error message to be written to standard output and log file
        @type _strMessage: python string
        """
        self.edLogging.WARNING(_strMessage)

    def warning(self, _strMessage=""):
        """
        This method writes a warning message to standard output and the log file with the prefix [Warning].
        
        @param _strMessage: The error message to be written to standard output and log file
        @type _strMessage: python string
        """
        self.edLogging.warning(_strMessage)

    def ASSERT(self, _strMessage):
        """
        This method writes an assert message to standard output and the log file with the prefix [ASSERT].
        
        @param _strMessage: The error message to be written to standard output and log file
        @type _strMessage: python string
        """
        self.edLogging.ASSERT(_strMessage)

    def writeErrorTrace(self, _strPrefix="  "):
        """
        This method writes an error trace to standard output and the log file. The error trace has
        the same formatting as normal Python error traces.
        
        @param _strPrefix: A prefix which can be customized, e.g. the testing framework uses '  [UnitTest]'
        @type _strPrefix: python string
        """
        self.edLogging.writeErrorTrace(_strPrefix)

    def setLogFileName(self, _strLogFileName):
        """
        This method can be used for customising the file name of the log file.
        
        @param _strLogFileName: A file name for the log file.
        @type _strLogFileName: python string
        """
        self.edLogging.setLogFileName(_strLogFileName)

    def setLogFileOff(self):
        """
        This method truns off output to the log file.
        """
        self.edLogging.setLogFileOff()
示例#3
0
class EDLogging(EDObject):
    """
    This class loads one of the EDNA loggers: EDLoggingVerbose, EDLoggingClass
    """


    def __init__(self, _strLoggerName="EDVerbose"):
        EDObject.__init__(self)
        if _strLoggerName == "PyLogging":
            self.edLogging = EDLoggingPyLogging()
        else:
            self.edLogging = EDLoggingVerbose()


    def setLogLevel(self, _logLevel):
        self.edLogging.setLogLevel(_logLevel)


    def setAllLogLevels(self, _logLevel):
        self.edLogging.setAllLogLevels(_logLevel)


    def setTestOn(self):
        """
        turn on the test mode: all assertions become verbose (->screen) 
        """
        self.edLogging.setTestOn()


    def setTestOff(self):
        """
        turn off the test mode: all assertions become silent (->screen) 
        """
        self.edLogging.setTestOff()


    def setVerboseOn(self):
        """
        This method turns on verbose logging to standard output (stdout)
        """
        self.edLogging.setVerboseOn()


    def setVerboseOff(self):
        """
        This method turns off verbose logging to standard output (stdout)
        """
        self.edLogging.setVerboseOff()


    def setVerboseDebugOn(self):
        """
        This method turns on debug messages to standard output and log file
        """
        self.edLogging.setVerboseDebugOn()


    def setVerboseDebugOff(self):
        """
        This method turns off debug messages to standard output and log file
        """
        self.edLogging.setVerboseDebugOff()


    def isVerboseDebug(self):
        """
        This method returns the current status of debugging
        
        @return: if debug output to standard output and log file is enabled.
        @type: boolean
        """
        return self.edLogging.isVerboseDebug()


    def log(self, _strMessage=""):
        """
        This method writes a message only to the log file.
        
        @param _strMessage: The string to be written to the log file
        @type _strMessage: python string
        """
        self.edLogging.log(_strMessage)

    def screen(self, _strMessage=""):
        """
        This method writes a message to standard output and to the log file.
        
        @param _strMessage: The string to be written to the log file
        @type _strMessage: python string
        """
        self.edLogging.screen(_strMessage)


    def DEBUG(self, _strDebugMessage=""):
        """
        This method writes a debug message to standard output and to the log file
        if debugging is enabled. The message will be written with the prefix [DEBUG]
        
        @param _strDebugMessage: The debug message to be written to standard output and log file
        @type _strDebugMessage: python string
        """
        self.edLogging.DEBUG(_strDebugMessage)


    def unitTest(self, _strMessage=""):
        """
        This method is meant to be used by the testing framework. The message will be written 
        to standard output and the log file with the prefix [UnitTest]
        
        @param _strMessage: The message to be written to standard output and log file
        @type _strMessage: python string
        """
        self.edLogging.unitTest(_strMessage)


    def ERROR(self, _strMessage=""):
        """
        This method writes a message to standard error and the log file with the prefix [ERROR].
        
        @param _strMessage: The error message to be written to standard output and log file
        @type _strMessage: python string
        """
        self.edLogging.ERROR(_strMessage)


    def error(self, _strMessage=""):
        """
        This method writes a message to standard error and the log file with the prefix [ERROR].
        
        @param _strMessage: The error message to be written to standard output and log file
        @type _strMessage: python string
        """
        self.edLogging.error(_strMessage)


    def WARNING(self, _strMessage=""):
        """
        This method writes a warning message to standard output and the log file with the prefix [Warning].
        
        @param _strMessage: The error message to be written to standard output and log file
        @type _strMessage: python string
        """
        self.edLogging.WARNING(_strMessage)



    def warning(self, _strMessage=""):
        """
        This method writes a warning message to standard output and the log file with the prefix [Warning].
        
        @param _strMessage: The error message to be written to standard output and log file
        @type _strMessage: python string
        """
        self.edLogging.warning(_strMessage)


    def ASSERT(self, _strMessage):
        """
        This method writes an assert message to standard output and the log file with the prefix [ASSERT].
        
        @param _strMessage: The error message to be written to standard output and log file
        @type _strMessage: python string
        """
        self.edLogging.ASSERT(_strMessage)

    def writeErrorTrace(self, _strPrefix="  "):
        """
        This method writes an error trace to standard output and the log file. The error trace has
        the same formatting as normal Python error traces.
        
        @param _strPrefix: A prefix which can be customized, e.g. the testing framework uses '  [UnitTest]'
        @type _strPrefix: python string
        """
        self.edLogging.writeErrorTrace(_strPrefix)


    def setLogFileName(self, _strLogFileName):
        """
        This method can be used for customising the file name of the log file.
        
        @param _strLogFileName: A file name for the log file.
        @type _strLogFileName: python string
        """
        self.edLogging.setLogFileName(_strLogFileName)


    def setLogFileOff(self):
        """
        This method truns off output to the log file.
        """
        self.edLogging.setLogFileOff()
示例#4
0
 def __init__(self, _strName=None):
     EDObject.__init__(self)
     self.edLogging = EDLoggingVerbose()
示例#5
0
 def __init__(self, _strLoggerName=None):
     EDObject.__init__(self)
     if _strLoggerName == "PyLogging":
         self.edLogging = EDLoggingPyLogging()
     else:
         self.edLogging = EDLoggingVerbose()
示例#6
0
文件: EDLogging.py 项目: rentreg/edna
 def __init__(self, _strName=None):
     EDObject.__init__(self)
     self.edLogging = EDLoggingVerbose()
示例#7
0
文件: EDLogging.py 项目: kif/edna
class EDLogging(EDObject):
    """
    This class loads one of the EDNA loggers: EDLoggingVerbose, EDLoggingClass
    """


    def __init__(self, _strLoggerName="EDVerbose"):
        EDObject.__init__(self)
        if _strLoggerName == "PyLogging":
            self.edLogging = EDLoggingPyLogging()
        else:
            self.edLogging = EDLoggingVerbose()
        self.__messages = []

    def setLogLevel(self, _logLevel):
        self.edLogging.setLogLevel(_logLevel)


    def setAllLogLevels(self, _logLevel):
        self.edLogging.setAllLogLevels(_logLevel)


    def setTestOn(self):
        """
        turn on the test mode: all assertions become verbose (->screen)
        """
        self.edLogging.setTestOn()


    def setTestOff(self):
        """
        turn off the test mode: all assertions become silent (->screen)
        """
        self.edLogging.setTestOff()


    def setVerboseOn(self):
        """
        This method turns on verbose logging to standard output (stdout)
        """
        self.edLogging.setVerboseOn()


    def setVerboseOff(self):
        """
        This method turns off verbose logging to standard output (stdout)
        """
        self.edLogging.setVerboseOff()


    def setVerboseDebugOn(self):
        """
        This method turns on debug messages to standard output and log file
        """
        self.edLogging.setVerboseDebugOn()


    def setVerboseDebugOff(self):
        """
        This method turns off debug messages to standard output and log file
        """
        self.edLogging.setVerboseDebugOff()


    def isVerboseDebug(self):
        """
        This method returns the current status of debugging

        @return: if debug output to standard output and log file is enabled.
        @type: boolean
        """
        return self.edLogging.isVerboseDebug()


    def log(self, _strMessage=""):
        """
        This method writes a message only to the log file.

        @param _strMessage: The string to be written to the log file
        @type _strMessage: python string
        """
        self.edLogging.log(_strMessage)

    def screen(self, _strMessage=""):
        """
        This method writes a message to standard output and to the log file.

        @param _strMessage: The string to be written to the log file
        @type _strMessage: python string
        """
        self.edLogging.screen(_strMessage)


    def DEBUG(self, _strDebugMessage=""):
        """
        This method writes a debug message to standard output and to the log file
        if debugging is enabled. The message will be written with the prefix [DEBUG]

        @param _strDebugMessage: The debug message to be written to standard output and log file
        @type _strDebugMessage: python string
        """
        self.edLogging.DEBUG(_strDebugMessage)


    def unitTest(self, _strMessage=""):
        """
        This method is meant to be used by the testing framework. The message will be written
        to standard output and the log file with the prefix [UnitTest]

        @param _strMessage: The message to be written to standard output and log file
        @type _strMessage: python string
        """
        self.edLogging.unitTest(_strMessage)


    def error(self, _strMessage=""):
        """
        This method writes a message to standard error and the log file with the prefix [ERROR].

        @param _strMessage: The error message to be written to standard output and log file
        @type _strMessage: python string
        """
        self.edLogging.error(_strMessage)
        self.__messages.append("Error:   %s" % _strMessage)
    ERROR = error


    def warning(self, _strMessage=""):
        """
        This method writes a warning message to standard output and the log file with the prefix [Warning].

        @param _strMessage: The error message to be written to standard output and log file
        @type _strMessage: python string
        """
        self.edLogging.warning(_strMessage)
        self.__messages.append("Warning: %s" % _strMessage)
    WARNING = warning


    def getXSDataMessage(self):
        """
        return a XSDataMessage with:
        Error:   tototo
        Warning: blabla
        """
        if self.__messages:
            return XSDataMessage(text=XSDataString(os.linesep.join(self.__messages)))
        #else return None


    def retrieveMessages(self, _edPlugin):
        """
        Propagates error/warning messages from a plugin
        if _bFailure is true, this method has been called from retrieveFailureMessages
        in this case, checks for potential unexpected errors coming from the EDPluginExec
        """
        if _edPlugin and _edPlugin.dataOutput and _edPlugin.dataOutput.status and \
            _edPlugin.dataOutput.status.message and  _edPlugin.dataOutput.status.message.text:
            with self.locked():
                self.__messages.append("%s-%08i:" % (_edPlugin.getClassName(), _edPlugin.getId()))
                for i in _edPlugin.dataOutput.status.message.text.value.split(os.linesep):
                    self.__messages.append("    " + i)



    def ASSERT(self, _strMessage):
        """
        This method writes an assert message to standard output and the log file with the prefix [ASSERT].

        @param _strMessage: The error message to be written to standard output and log file
        @type _strMessage: python string
        """
        self.edLogging.ASSERT(_strMessage)

    def writeErrorTrace(self, _strPrefix="  "):
        """
        This method writes an error trace to standard output and the log file. The error trace has
        the same formatting as normal Python error traces.

        @param _strPrefix: A prefix which can be customized, e.g. the testing framework uses '  [UnitTest]'
        @type _strPrefix: python string
        """
        self.edLogging.writeErrorTrace(_strPrefix)


    def setLogFileName(self, _strLogFileName):
        """
        This method can be used for customising the file name of the log file.

        @param _strLogFileName: A file name for the log file.
        @type _strLogFileName: python string
        """
        self.edLogging.setLogFileName(_strLogFileName)


    def setLogFileOff(self):
        """
        This method truns off output to the log file.
        """
        self.edLogging.setLogFileOff()