/usr/lib/python2.7/dist-packages/librtmp/logging.py is in python-librtmp 0.3.0-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 | from . import ffi, librtmp
from .utils import add_signal_handler
__all__ = ["set_log_level", "get_log_level",
"set_log_output", "add_log_callback", "remove_log_callback",
"LOG_CRIT", "LOG_ERROR", "LOG_WARNING",
"LOG_INFO", "LOG_DEBUG", "LOG_DEBUG2",
"LOG_ALL"]
(LOG_CRIT, LOG_ERROR, LOG_WARNING, LOG_INFO, LOG_DEBUG,
LOG_DEBUG2, LOG_ALL) = range(1, 8)
_log_callbacks = set()
_log_level = LOG_ALL
_log_output = None
def set_log_level(level):
"""Sets log level."""
global _log_level
_log_level = level
def get_log_level():
"""Returns current log level."""
return _log_level
def set_log_output(fd):
"""Sets log output to a open file-object."""
global _log_output
_log_output = fd
def add_log_callback(callback):
"""Adds a log callback."""
global _log_callbacks
if not callable(callback):
raise ValueError("Callback must be callable")
_log_callbacks.add(callback)
return callback
def remove_log_callback(callback):
"""Removes a log callback."""
global _log_callbacks
_log_callbacks.remove(callback)
@ffi.callback("void(int,char*)")
def _log_callback(level, msg):
msg = ffi.string(msg)
msg = msg.decode("utf8", "ignore")
for callback in _log_callbacks:
callback(level, msg)
if hasattr(_log_output, "write") and level <= _log_level:
_log_output.write(msg + "\n")
librtmp.python_log_callback = _log_callback
librtmp.RTMP_LogSetCallback(librtmp.c_log_callback)
add_signal_handler()
|