Python sphinx.util.logging.getLogger() Examples

The following are 7 code examples of sphinx.util.logging.getLogger(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module sphinx.util.logging , or try the search function .
Example #1
Source File: conf.py    From pytest with MIT License 6 votes vote down vote up
def configure_logging(app: "sphinx.application.Sphinx") -> None:
    """Configure Sphinx's WarningHandler to handle (expected) missing include."""
    import sphinx.util.logging
    import logging

    class WarnLogFilter(logging.Filter):
        def filter(self, record: logging.LogRecord) -> bool:
            """Ignore warnings about missing include with "only" directive.

            Ref: https://github.com/sphinx-doc/sphinx/issues/2150."""
            if (
                record.msg.startswith('Problems with "include" directive path:')
                and "_changelog_towncrier_draft.rst" in record.msg
            ):
                return False
            return True

    logger = logging.getLogger(sphinx.util.logging.NAMESPACE)
    warn_handler = [x for x in logger.handlers if x.level == logging.WARNING]
    assert len(warn_handler) == 1, warn_handler
    warn_handler[0].filters.insert(0, WarnLogFilter()) 
Example #2
Source File: conf.py    From python-zhmcclient with Apache License 2.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        self._logger = logging.getLogger(__name__)  # requires Sphinx 1.6.1
        self._log_prefix = "conf.py/AutoAutoSummary"
        self._excluded_classes = ['BaseException']
        super(AutoAutoSummary, self).__init__(*args, **kwargs) 
Example #3
Source File: builder.py    From sphinxcontrib-needs with MIT License 5 votes vote down vote up
def finish(self):
        log = logging.getLogger(__name__)
        needs = self.env.needs_all_needs
        filters = self.env.needs_all_filters
        config = self.env.config
        version = config.version
        needs_list = NeedsList(config, self.outdir, self.confdir)

        needs_list.load_json()

        # Clean needs_list from already stored needs of the current version.
        # This is needed as needs could have been removed from documentation and if this is the case,
        # removed needs would stay in needs_list, if list gets not cleaned.
        needs_list.wipe_version(version)

        for key, need in needs.items():
            needs_list.add_need(version, need)

        for key, need_filter in filters.items():
            if need_filter['export_id']:
                needs_list.add_filter(version, need_filter)

        try:
            needs_list.write_json()
        except Exception as e:
            log.error("Error during writing json file: {0}".format(e))
        else:
            log.info("Needs successfully exported") 
Example #4
Source File: need.py    From sphinxcontrib-needs with MIT License 5 votes vote down vote up
def __init__(self, *args, **kw):
        super(NeedDirective, self).__init__(*args, **kw)
        self.log = logging.getLogger(__name__)
        self.full_title = self._get_full_title() 
Example #5
Source File: utils.py    From sphinxcontrib-needs with MIT License 5 votes vote down vote up
def __init__(self, config, outdir, confdir):
        self.log = logging.getLogger(__name__)
        self.config = config
        self.outdir = outdir
        self.confdir = confdir
        self.current_version = config.version
        self.project = config.project
        self.needs_list = {
            "project": self.project,
            "current_version": self.current_version,
            "created": "",
            "versions": {}} 
Example #6
Source File: conf.py    From gwin with GNU General Public License v3.0 5 votes vote down vote up
def build_includes(app):
    """Build extra include files from _includes dir
    """
    logger = logging.getLogger('includes')
    curdir = os.path.abspath(os.path.dirname(__file__))
    incdir = os.path.join(curdir, '_includes')
    for pyf in glob.glob(os.path.join(curdir, '_includes', '*.py')):
        rstfile = pyf.replace('.py', '.rst')
        logger.info('generating {0} from {1}'.format(rstfile, pyf))
        rst = subprocess.check_output([sys.executable, pyf])
        with open(rstfile, 'w') as f:
            f.write(rst)


# -- setup -------------------------------------------------------------------- 
Example #7
Source File: conf.py    From pywbem with GNU Lesser General Public License v2.1 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        self._logger = logging.getLogger(__name__)  # requires Sphinx 1.6.1
        self._log_prefix = "conf.py/AutoAutoSummary"
        self._excluded_classes = ['BaseException']
        super(AutoAutoSummary, self).__init__(*args, **kwargs)