This file is indexed.

/usr/share/pyshared/ZConfig/components/logger/logger.py is in python-zconfig 2.9.3-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
##############################################################################
#
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""ZConfig factory datatypes for loggers."""

from ZConfig.components.logger.factory import Factory


class LoggerFactoryBase(Factory):
    """Base class for logger factories.

    Factory used to create loggers while delaying actual logger
    instance construction.  We need to do this because we may want to
    reference a logger before actually instantiating it (for example,
    to allow the app time to set an effective user).  An instance of
    this wrapper is a callable which, when called, returns a logger
    object.
    """

    def __init__(self, section):
        Factory.__init__(self)
        self.level = section.level
        self.handler_factories = section.handlers

    def create(self):
        # set the logger up
        import logging
        logger = logging.getLogger(self.name)
        logger.setLevel(self.level)
        if self.handler_factories:
            for handler_factory in self.handler_factories:
                handler = handler_factory()
                logger.addHandler(handler)
        else:
            from ZConfig.components.logger import loghandler
            logger.addHandler(loghandler.NullHandler())
        return logger

    def startup(self):
        # make sure we've instantiated the logger
        self()

    def getLowestHandlerLevel(self):
        """Return the lowest log level provided by any configured handler.

        If all handlers and the logger itself have level==NOTSET, this
        returns NOTSET.
        """
        import logging
        lowest = self.level
        for factory in self.handler_factories:
            level = factory.getLevel()
            if level != logging.NOTSET:
                if lowest == logging.NOTSET:
                    lowest = level
                else:
                    lowest = min(lowest, level)
        return lowest

    def reopen(self):
        """Re-open any handlers for which this is a meaningful operation.

        This only works on handlers on the logger provided by this
        factory directly; handlers for child loggers are not affected.
        (This can be considered a bug, but is sufficient at the
        moment.)
        """
        logger = self()
        for handler in logger.handlers:
            reopen = getattr(handler, "reopen", None)
            if reopen is not None and callable(reopen):
                reopen()


class EventLogFactory(LoggerFactoryBase):
    """Logger factory that returns the root logger."""

    name = None


class LoggerFactory(LoggerFactoryBase):
    """Logger factory that returns the named logger."""

    def __init__(self, section):
        LoggerFactoryBase.__init__(self, section)
        self.name = section.name
        self.propagate = section.propagate

    def create(self):
        logger = LoggerFactoryBase.create(self)
        logger.propagate = self.propagate
        return logger