Next / Previous / Contents / Shipman's homepage

19. Log.count(): How many messages of a given kind?

logscan.py
# - - -   L o g . c o u n t

    def count(self, kind=None):
        '''Return the number of messages of a given kind.
        '''

We need to return zero if there have never been any messages of this kind. Otherwise, the count is in self.__kindCounts. The default kind is ERROR_KIND.

logscan.py
        #-- 1 --
        if kind is None:
             kind = ERROR_KIND

        #-- 2 --
        try:
            return self.__kindCounts[kind]
        except KeyError:
            return 0