Exemplo n.º 1
0
 def add(self, translatable):
     if not isinstance(translatable, Translatable):
         raise ValueError('%r is not Translatable' % translatable)
     self.translatables.append(translatable)
     log.doLog(log.DEBUG, None, 'messages',
         'message %r: adding %r', (id(self), translatable.untranslated()),
          where=-2)
Exemplo n.º 2
0
 def add(self, translatable):
     if not isinstance(translatable, Translatable):
         raise ValueError('%r is not Translatable' % translatable)
     self.translatables.append(translatable)
     log.doLog(log.DEBUG, None, 'messages',
         'message %r: adding %r', (id(self), translatable.untranslated()),
          where=-2)
Exemplo n.º 3
0
    def __init__(self,
                 level,
                 translatable,
                 debug=None,
                 mid=None,
                 priority=50,
                 timestamp=None):
        """
        Create a new message.

        The mid identifies this kind of message, and serves two purposes.

        The first purpose is to serve as a key by which a kind of
        message might be removed from a set of messages. For example, a
        firewire component detecting that a cable has been plugged in
        will remove any message that the cable is unplugged.

        Secondly it serves so that the message viewers that watch the
        'current state' of some object only see the latest message of a
        given type. For example when messages are stored in persistent
        state objects that can be transferred over the network, it
        becomes inefficient to store the whole history of status
        messages. Message stores can keep only the latest message of a
        given ID.

        @param level:        ERROR, WARNING or INFO
        @param translatable: a translatable possibly with markup for
                             linking to documentation or running commands.
        @param debug:        further, untranslated, debug information, not
                             always shown
        @param priority:     priority compared to other messages of the same
                             level
        @param timestamp:    time since epoch at which the message was
                             generated, in seconds.
        @param mid:          A unique id for this kind of message, as
                             discussed above. If not given, will be
                             generated from the contents of the
                             translatable.
        """
        self.level = level
        self.translatables = []
        self.debug = debug

        # FIXME: untranslated is a really poor choice of id
        self.id = mid or translatable.untranslated()
        self.priority = priority
        self.timestamp = timestamp or time.time()
        # -1 is in __init__, -2 is in the subclass __init__,
        # -3 is in the caller
        log.doLog(log.DEBUG,
                  None,
                  'messages',
                  'creating message %r',
                  self,
                  where=-3)
        log.doLog(log.DEBUG, None, 'messages', 'message debug %s', debug)
        self.add(translatable)
Exemplo n.º 4
0
    def __init__(self, level, translatable, debug=None, id=None, priority=50,
        timestamp=None, mid=None):
        """
        Create a new message.

        The id identifies this kind of message, and serves two purposes.

        The first purpose is to serve as a key by which a kind of
        message might be removed from a set of messages. For example, a
        firewire component detecting that a cable has been plugged in
        will remove any message that the cable is unplugged.

        Secondly it serves so that the message viewers that watch the
        'current state' of some object only see the latest message of a
        given type. For example when messages are stored in persistent
        state objects that can be transferred over the network, it
        becomes inefficient to store the whole history of status
        messages. Message stores can keep only the latest message of a
        given ID.

        @param level:        ERROR, WARNING or INFO
        @param translatable: a translatable possibly with markup for
                             linking to documentation or running commands.
        @param debug:        further, untranslated, debug information, not
                             always shown
        @param priority:     priority compared to other messages of the same
                             level
        @param timestamp:    time since epoch at which the message was
                             generated, in seconds.
        @param mid:          A unique id for this kind of message, as
                             discussed above. If not given, will be
                             generated from the contents of the
                             translatable.
        """
        self.level = level
        self.translatables = []
        self.debug = debug
        if id:
            import warnings
            warnings.warn('Please use the mid kwarg instead',
                DeprecationWarning, stacklevel=3)
            mid = id

        # FIXME: untranslated is a really poor choice of id
        self.id = mid or translatable.untranslated()
        self.priority = priority
        self.timestamp = timestamp or time.time()
        # -1 is in __init__, -2 is in the subclass __init__,
        # -3 is in the caller
        log.doLog(log.DEBUG, None, 'messages',
            'creating message %r', self, where=-3)
        log.doLog(log.DEBUG, None, 'messages',
            'message debug %s', debug)
        self.add(translatable)
Exemplo n.º 5
0
def error(format, *args):
    flog.doLog(flog.ERROR, None, 'integration', format, args, -2)
Exemplo n.º 6
0
def warning(format, *args):
    flog.doLog(flog.WARN, None, 'integration', format, args, -2)
Exemplo n.º 7
0
def info(format, *args):
    flog.doLog(flog.INFO, None, 'integration', format, args, -2)
Exemplo n.º 8
0
def debug(format, *args):
    flog.doLog(flog.DEBUG, None, 'integration', format, args, -2)
Exemplo n.º 9
0
def log(format, *args):
    flog.doLog(flog.LOG, None, 'integration', format, args, -2)
Exemplo n.º 10
0
def error(format, *args):
    flog.doLog(flog.ERROR, None, 'integration', format, args, -2)
Exemplo n.º 11
0
def warning(format, *args):
    flog.doLog(flog.WARN, None, 'integration', format, args, -2)
Exemplo n.º 12
0
def info(format, *args):
    flog.doLog(flog.INFO, None, 'integration', format, args, -2)
Exemplo n.º 13
0
def debug(format, *args):
    flog.doLog(flog.DEBUG, None, 'integration', format, args, -2)
Exemplo n.º 14
0
def log(format, *args):
    flog.doLog(flog.LOG, None, 'integration', format, args, -2)