def _fix_logging_shortcuts(cls):
        """
        Fix standard logging shortcuts to correctly report logging module.

        This is only useful if you:
        - actually use %(name) and care about it being correct
        - you would still like to use the logging.info() etc shortcuts

        So basically you'd like to write this:
            import logging
            logging.info("hello")

        Instead of this:
            import logging
            LOG = logging.getLogger(__name__)
            LOG.info("hello")
        """
        if cls.is_using_format("%(pathname)s %(filename)s %(funcName)s %(module)s"):
            logging._srcfile = cls._logging_snapshot._srcfile
        else:
            logging._srcfile = None

        logging.logProcesses = cls.is_using_format("%(process)d")
        logging.logThreads = cls.is_using_format("%(thread)d %(threadName)s")

        def getframe():
            return sys._getframe(4)

        def log(level, msg, *args, **kwargs):
            """Wrapper to make logging.info() etc report the right module %(name)"""
            name = get_caller_name()
            logger = logging.getLogger(name)
            try:
                logging.currentframe = getframe
                logger.log(level, msg, *args, **kwargs)
            finally:
                logging.currentframe = ORIGINAL_CF

        def wrap(level, **kwargs):
            """Wrap corresponding logging shortcut function"""
            original = getattr(logging, logging.getLevelName(level).lower())
            f = partial(log, level, **kwargs)
            f.__doc__ = original.__doc__
            return f

        logging.critical = wrap(logging.CRITICAL)
        logging.fatal = logging.critical
        logging.error = wrap(logging.ERROR)
        logging.exception = partial(logging.error, exc_info=True)
        logging.warning = wrap(logging.WARNING)
        logging.info = wrap(logging.INFO)
        logging.debug = wrap(logging.DEBUG)
        logging.log = log
def _fix_logging_shortcuts ( cls ) : if cls . is_using_format ( "%(pathname)s %(filename)s %(funcName)s %(module)s" ) : logging . _srcfile = cls . _logging_snapshot . _srcfile else : logging . _srcfile = None logging . logProcesses = cls . is_using_format ( "%(process)d" ) logging . logThreads = cls . is_using_format ( "%(thread)d %(threadName)s" ) def getframe ( ) : return sys . _getframe ( 4 ) def log ( level , msg , * args , ** kwargs ) : name = get_caller_name ( ) logger = logging . getLogger ( name ) try : logging . currentframe = getframe logger . log ( level , msg , * args , ** kwargs ) finally : logging . currentframe = ORIGINAL_CF def wrap ( level , ** kwargs ) : original = getattr ( logging , logging . getLevelName ( level ) . lower ( ) ) f = partial ( log , level , ** kwargs ) f . __doc__ = original . __doc__ return f logging . critical = wrap ( logging . CRITICAL ) logging . fatal = logging . critical logging . error = wrap ( logging . ERROR ) logging . exception = partial ( logging . error , exc_info = True ) logging . warning = wrap ( logging . WARNING ) logging . info = wrap ( logging . INFO ) logging . debug = wrap ( logging . DEBUG ) logging . log = log
Fix standard logging shortcuts to correctly report logging module.

        This is only useful if you:
        - actually use %(name) and care about it being correct
        - you would still like to use the logging.info() etc shortcuts

        So basically you'd like to write this:
            import logging
            logging.info("hello")

        Instead of this:
            import logging
            LOG = logging.getLogger(__name__)
            LOG.info("hello")