This file is indexed.

/usr/lib/python2.7/dist-packages/pylons/log.py is in python-pylons 1.0.2-1.

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
"""Logging related functionality

This logging Handler logs to ``environ['wsgi.errors']`` as designated
in :pep:`333`.

"""
import logging
import types

import pylons

__all__ = ['WSGIErrorsHandler']


class WSGIErrorsHandler(logging.Handler):

    """A handler class that writes logging records to
    `environ['wsgi.errors']`.

    This code is derived from CherryPy's
    :class:`cherrypy._cplogging.WSGIErrorHandler`.

    ``cache``
        Whether the `wsgi.errors` stream is cached (instead of looked up
        via `pylons.request.environ` per every logged message). Enabling
        this option is not recommended (particularly for the use case of
        logging to `wsgi.errors` outside of a request) as the behavior
        of a cached `wsgi.errors` stream is not strictly defined. In
        particular, `mod_wsgi <http://www.modwsgi.org>`_'s `wsgi.errors`
        will raise an exception when used outside of a request.

    """

    def __init__(self, cache=False, *args, **kwargs):
        logging.Handler.__init__(self, *args, **kwargs)
        self.cache = cache
        self.cached_stream = None

    def get_wsgierrors(self):
        """Return the wsgi.errors stream

        Raises a TypeError when outside of a web request
        (pylons.request is not setup)

        """
        if not self.cache:
            return pylons.request.environ.get('wsgi.errors')
        elif not self.cached_stream:
            self.cached_stream = pylons.request.environ.get('wsgi.errors')
            return self.cached_stream
        return self.cached_stream

    def flush(self):
        """Flushes the stream"""
        try:
            stream = self.get_wsgierrors()
        except TypeError:
            pass
        else:
            if stream:
                stream.flush()

    def emit(self, record):
        """Emit a record"""
        try:
            stream = self.get_wsgierrors()
        except TypeError:
            pass
        else:
            if not stream:
                return
            try:
                msg = self.format(record)
                fs = "%s\n"
                if not hasattr(types, "UnicodeType"):  # if no unicode support
                    stream.write(fs % msg)
                else:
                    try:
                        stream.write(fs % msg)
                    except UnicodeError:
                        stream.write(fs % msg.encode("UTF-8"))
                self.flush()
            except (KeyboardInterrupt, SystemExit):
                raise
            except:
                self.handleError(record)