Ejemplo n.º 1
0
    def __init__(self, instance):
        """
        Initialise the class with the calling module.

        Private variables (altered):
            - _outputdata ; The output dictionary.
            - _messages   ; The messages list.
            - _instance   ; Initialised with the name of the module that
                             created this object.
            - _loghandle  ; Initialised as the handle of the log file
                             defined in the configuration file.
            - _errors     ; Initialised to 0.
            - _warnings   ; Initialised to 0.

        @arg instance: The filename of the module that created this object
        @type instance: unicode
        """
        self._outputData = {}
        self._messages = []
        self._instance = util.nice_filename(instance)
        self._loghandle = io.open(settings.LOG_FILE,
                                  mode='a+',
                                  encoding='utf-8')
        self._errors = 0
        self._warnings = 0
Ejemplo n.º 2
0
    def addMessage(self, filename, level, code, description) :
        """
        Add a message to the message list.
        If the level exceeds the configured loglevel or if the level is -1,
        then the message is also logged.
        If the severity equals 2, then the number of warnings is inreased,
        if it exceeds 2, then the number of errors is increased.

        Private variables:
            - _messages  ; The messages list.
            - _instance  ; Module that created the Output object.
            - _loghandle ; Handle to the log file.

        Private variables (altered):
            - _warnings ; Increased by one if the severity equals 2.
            - _errors   ; Increased by one if the severity exceeds 2.

        @arg filename:    Name of the calling module
        @arg level:       Severity of the message
        @arg code:        Error code of the message
        @arg description: Description of the message
        """
        nice_name = util.nice_filename(filename)
        message = Message(nice_name, level, code, description)

        # Append a new message object to the messages list.
        self._messages.append(message)

        if level == 2:
            self._warnings += 1
        if level > 2:
            self._errors += 1

        # Log the message if the message is important enough, or if it is only
        # meant to be logged (level -1).
        if level >= settings.LOG_LEVEL or level == -1 :
            self._loghandle.write(time.strftime(
                settings.LOG_TIME_FORMAT + ' ') + "%s (%s) %s: %s: %s\n" % (
                    self._instance, nice_name, code, message.named_level(),
                    description))
            self._loghandle.flush()
Ejemplo n.º 3
0
    def addMessage(self, filename, level, code, description):
        """
        Add a message to the message list.
        If the level exceeds the configured loglevel or if the level is -1,
        then the message is also logged.
        If the severity equals 2, then the number of warnings is inreased,
        if it exceeds 2, then the number of errors is increased.

        Private variables:
            - _messages  ; The messages list.
            - _instance  ; Module that created the Output object.
            - _loghandle ; Handle to the log file.

        Private variables (altered):
            - _warnings ; Increased by one if the severity equals 2.
            - _errors   ; Increased by one if the severity exceeds 2.

        @arg filename:    Name of the calling module
        @arg level:       Severity of the message
        @arg code:        Error code of the message
        @arg description: Description of the message
        """
        nice_name = util.nice_filename(filename)
        message = Message(nice_name, level, code, description)

        # Append a new message object to the messages list.
        self._messages.append(message)

        if level == 2:
            self._warnings += 1
        if level > 2:
            self._errors += 1

        # Log the message if the message is important enough, or if it is only
        # meant to be logged (level -1).
        if level >= settings.LOG_LEVEL or level == -1:
            self._loghandle.write(
                time.strftime(settings.LOG_TIME_FORMAT + ' ') +
                "%s (%s) %s: %s: %s\n" % (self._instance, nice_name, code,
                                          message.named_level(), description))
            self._loghandle.flush()
Ejemplo n.º 4
0
    def __init__(self, instance):
        """
        Initialise the class with the calling module.

        Private variables (altered):
            - _outputdata ; The output dictionary.
            - _messages   ; The messages list.
            - _instance   ; Initialised with the name of the module that
                             created this object.
            - _loghandle  ; Initialised as the handle of the log file
                             defined in the configuration file.
            - _errors     ; Initialised to 0.
            - _warnings   ; Initialised to 0.

        @arg instance: The filename of the module that created this object
        @type instance: unicode
        """
        self._outputData = {}
        self._messages = []
        self._instance = util.nice_filename(instance)
        self._loghandle = io.open(settings.LOG_FILE, mode='a+',
                                  encoding='utf-8')
        self._errors = 0
        self._warnings = 0