/usr/lib/python2.7/dist-packages/livestreamer/logger.py is in python-livestreamer 1.12.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 | import sys
from threading import Lock
class Logger(object):
Levels = ["none", "error", "warning", "info", "debug"]
Format = "[{module}][{level}] {msg}\n"
def __init__(self):
self.output = sys.stdout
self.level = 0
self.lock = Lock()
def new_module(self, module):
return LoggerModule(self, module)
def set_level(self, level):
try:
index = Logger.Levels.index(level)
except ValueError:
return
self.level = index
def set_output(self, output):
self.output = output
def msg(self, module, level, msg, *args, **kwargs):
if self.level < level or level > len(Logger.Levels):
return
msg = msg.format(*args, **kwargs)
with self.lock:
self.output.write(Logger.Format.format(module=module,
level=Logger.Levels[level],
msg=msg))
if hasattr(self.output, "flush"):
self.output.flush()
class LoggerModule(object):
def __init__(self, manager, module):
self.manager = manager
self.module = module
def error(self, msg, *args, **kwargs):
self.manager.msg(self.module, 1, msg, *args, **kwargs)
def warning(self, msg, *args, **kwargs):
self.manager.msg(self.module, 2, msg, *args, **kwargs)
def info(self, msg, *args, **kwargs):
self.manager.msg(self.module, 3, msg, *args, **kwargs)
def debug(self, msg, *args, **kwargs):
self.manager.msg(self.module, 4, msg, *args, **kwargs)
__all__ = ["Logger"]
|