本文整理汇总了Python中sphinx.util.logging.getLogger方法的典型用法代码示例。如果您正苦于以下问题:Python logging.getLogger方法的具体用法?Python logging.getLogger怎么用?Python logging.getLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sphinx.util.logging
的用法示例。
在下文中一共展示了logging.getLogger方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure_logging
# 需要导入模块: from sphinx.util import logging [as 别名]
# 或者: from sphinx.util.logging import getLogger [as 别名]
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())
示例2: __init__
# 需要导入模块: from sphinx.util import logging [as 别名]
# 或者: from sphinx.util.logging import getLogger [as 别名]
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)
示例3: finish
# 需要导入模块: from sphinx.util import logging [as 别名]
# 或者: from sphinx.util.logging import getLogger [as 别名]
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")
示例4: __init__
# 需要导入模块: from sphinx.util import logging [as 别名]
# 或者: from sphinx.util.logging import getLogger [as 别名]
def __init__(self, *args, **kw):
super(NeedDirective, self).__init__(*args, **kw)
self.log = logging.getLogger(__name__)
self.full_title = self._get_full_title()
示例5: __init__
# 需要导入模块: from sphinx.util import logging [as 别名]
# 或者: from sphinx.util.logging import getLogger [as 别名]
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": {}}
示例6: build_includes
# 需要导入模块: from sphinx.util import logging [as 别名]
# 或者: from sphinx.util.logging import getLogger [as 别名]
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 --------------------------------------------------------------------