/usr/lib/python2.7/dist-packages/mipp/log.py is in python-mipp 1.0.0-3.
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 os
import logging as log
class NullHandler(log.Handler):
"""Empty handler.
"""
def emit(self, record):
"""Record a message.
"""
pass
def debug_on():
"""Turn debugging logging on.
"""
logging_on(log.DEBUG)
_format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
_is_logging_on = False
def logging_on(level=None):
"""Turn logging on.
"""
global _is_logging_on
if level == None:
if os.environ.get("DEBUG", ''):
level = log.DEBUG
else:
level = log.INFO
if not _is_logging_on:
console = log.StreamHandler()
console.setFormatter(log.Formatter(_format, '%Y-%m-%d %H:%M:%S'))
console.setLevel(level)
log.getLogger('').addHandler(console)
_is_logging_on = True
logger = log.getLogger('')
logger.setLevel(level)
for handler in logger.handlers:
handler.setLevel(level)
def logging_off():
"""Turn logging off.
"""
global _is_logging_on
logger = log.getLogger('')
for handler in logger.handlers:
handler.close()
logger.removeHandler(handler)
logger.handlers = [NullHandler()]
_is_logging_on = False
def get_logger(name):
"""Return logger with null handle
"""
logger = log.getLogger(name)
if not logger.handlers:
logger.addHandler(NullHandler())
return logger
|