This file is indexed.

/usr/lib/python2.7/dist-packages/tmuxp/log.py is in python-tmuxp 1.3.5-2.

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
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Log utilities for tmuxp.

tmuxp.log
~~~~~~~~~

"""
from __future__ import (absolute_import, division, print_function,
                        unicode_literals, with_statement)

import logging
import time

from colorama import Fore, Style

LEVEL_COLORS = {
    'DEBUG': Fore.BLUE,  # Blue
    'INFO': Fore.GREEN,  # Green
    'WARNING': Fore.YELLOW,
    'ERROR': Fore.RED,
    'CRITICAL': Fore.RED
}


def default_log_template(self, record):
    """Return the prefix for the log message. Template for Formatter.

    :param: record: :py:class:`logging.LogRecord` object. this is passed in
    from inside the :py:meth:`logging.Formatter.format` record.

    """

    reset = Style.RESET_ALL
    levelname = (
        LEVEL_COLORS.get(record.levelname) + Style.BRIGHT +
        '(%(levelname)s)' + Style.RESET_ALL + ' '
    )
    asctime = (
        '[' + Fore.BLACK + Style.DIM + Style.BRIGHT +
        '%(asctime)s' + Fore.RESET + Style.RESET_ALL + ']'
    )
    name = (
        ' ' + Fore.WHITE + Style.DIM + Style.BRIGHT +
        '%(name)s' + Fore.RESET + Style.RESET_ALL + ' '
    )

    tpl = reset + levelname + asctime + name + reset

    return tpl


class LogFormatter(logging.Formatter):
    template = default_log_template

    def __init__(self, color=True, *args, **kwargs):
        logging.Formatter.__init__(self, *args, **kwargs)

    def format(self, record):
        try:
            record.message = record.getMessage()
        except Exception as e:
            record.message = "Bad message (%r): %r" % (e, record.__dict__)

        date_format = '%H:%m:%S'
        record.asctime = time.strftime(
            date_format, self.converter(record.created)
        )

        prefix = self.template(record) % record.__dict__

        formatted = prefix + " " + record.message
        return formatted.replace("\n", "\n    ")


def debug_log_template(self, record):
    """ Return the prefix for the log message. Template for Formatter.

    :param: record: :py:class:`logging.LogRecord` object. this is passed in
    from inside the :py:meth:`logging.Formatter.format` record.

    """

    reset = Style.RESET_ALL
    levelname = (
        LEVEL_COLORS.get(record.levelname) + Style.BRIGHT +
        '(%(levelname)1.1s)' + Style.RESET_ALL + ' '
    )
    asctime = (
        '[' + Fore.BLACK + Style.DIM + Style.BRIGHT +
        '%(asctime)s' + Fore.RESET + Style.RESET_ALL + ']'
    )
    name = (
        ' ' + Fore.WHITE + Style.DIM + Style.BRIGHT +
        '%(name)s' + Fore.RESET + Style.RESET_ALL + ' '
    )
    module_funcName = (
        Fore.GREEN + Style.BRIGHT +
        '%(module)s.%(funcName)s()'
    )
    lineno = (
        Fore.BLACK + Style.DIM + Style.BRIGHT + ':' + Style.RESET_ALL +
        Fore.CYAN + '%(lineno)d'
    )

    tpl = reset + levelname + asctime + name + module_funcName + lineno + reset

    return tpl


class DebugLogFormatter(LogFormatter):
    """Provides greater technical details than standard log Formatter."""

    template = debug_log_template