当前位置: 首页>>代码示例>>Python>>正文


Python log.DEFAULT_LOGGING属性代码示例

本文整理汇总了Python中django.utils.log.DEFAULT_LOGGING属性的典型用法代码示例。如果您正苦于以下问题:Python log.DEFAULT_LOGGING属性的具体用法?Python log.DEFAULT_LOGGING怎么用?Python log.DEFAULT_LOGGING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在django.utils.log的用法示例。


在下文中一共展示了log.DEFAULT_LOGGING属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _configure_logging

# 需要导入模块: from django.utils import log [as 别名]
# 或者: from django.utils.log import DEFAULT_LOGGING [as 别名]
def _configure_logging(self):
        """
        Setup logging from LOGGING_CONFIG and LOGGING settings.
        """
        if not sys.warnoptions:
            try:
                # Route warnings through python logging
                logging.captureWarnings(True)
                # Allow DeprecationWarnings through the warnings filters
                warnings.simplefilter("default", DeprecationWarning)
            except AttributeError:
                # No captureWarnings on Python 2.6, DeprecationWarnings are on anyway
                pass

        if self.LOGGING_CONFIG:
            from django.utils.log import DEFAULT_LOGGING
            # First find the logging configuration function ...
            logging_config_path, logging_config_func_name = self.LOGGING_CONFIG.rsplit('.', 1)
            logging_config_module = importlib.import_module(logging_config_path)
            logging_config_func = getattr(logging_config_module, logging_config_func_name)

            logging_config_func(DEFAULT_LOGGING)

            if self.LOGGING:
                # Backwards-compatibility shim for #16288 fix
                compat_patch_logging_config(self.LOGGING)

                # ... then invoke it with the logging settings
                logging_config_func(self.LOGGING) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:31,代码来源:__init__.py

示例2: configure_django_logging

# 需要导入模块: from django.utils import log [as 别名]
# 或者: from django.utils.log import DEFAULT_LOGGING [as 别名]
def configure_django_logging(verbosity: int, mode: LoggingMode):
    """Do basic logging configuration for Django, if possible.

    Then destroy Django's ability to mess with logging configuration. We have
    to do this by monkey-patching because changing Django's settings at
    run-time is not supported. If Django is not installed this is a no-op.

    :param verbosity: See `get_logging_level`.
    :param mode: The mode in which to configure logging. See `LoggingMode`.
    """
    try:
        from django.utils import log
    except ImportError:
        # Django not installed; nothing to be done.
        return

    # Django's default logging configuration is not great. For example it
    # wants to email request errors and security issues to the site admins,
    # but fails silently. Throw it all away.
    warn_unless(
        hasattr(log, "DEFAULT_LOGGING"),
        "No DEFAULT_LOGGING attribute found in Django; please investigate!",
    )
    log.DEFAULT_LOGGING = {"version": 1, "disable_existing_loggers": False}

    # Prevent Django from meddling with `warnings`. There's no configuration
    # option for this so we have to get invasive. We also skip running-in
    # Django's default log configuration even though we threw it away already.
    def configure_logging(logging_config, logging_settings):
        """Reduced variant of Django's configure_logging."""
        if logging_config is not None:
            logging_config_func = log.import_string(logging_config)
            logging_config_func(logging_settings)

    warn_unless(
        hasattr(log, "configure_logging"),
        "No configure_logging function found in Django; please investigate!",
    )
    log.configure_logging = configure_logging

    # Outside of the development environment ensure that deprecation warnings
    # from Django are silenced. End users are _not_ interested in deprecation
    # warnings from Django. Developers are, however.
    if not is_dev_environment():
        from django.utils.deprecation import RemovedInNextVersionWarning

        warnings.simplefilter("ignore", RemovedInNextVersionWarning) 
开发者ID:maas,项目名称:maas,代码行数:49,代码来源:_django.py


注:本文中的django.utils.log.DEFAULT_LOGGING属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。