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


Python Sandesh.uninit方法代码示例

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


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

示例1: KubeManagerLogger

# 需要导入模块: from pysandesh.sandesh_base import Sandesh [as 别名]
# 或者: from pysandesh.sandesh_base.Sandesh import uninit [as 别名]

#.........这里部分代码省略.........
        # Log to syslog.
        self.syslog(log_msg, log_level)

        # Log using the desired logging function.
        self.log(log_msg, level=log_level, fun=logging_fun)

    # WARNING.
    def warning(self, log_msg, log_fun=None):
        log_level = SandeshLevel.SYS_WARN
        logging_fun = log_fun if log_fun else sandesh.KubeManagerWarningLog

        # Log to syslog.
        self.syslog(log_msg, log_level)

        # Log using the desired logging function.
        self.log(log_msg, level=log_level, fun=logging_fun)

    # NOTICE.
    def notice(self, log_msg, log_fun=None):
        log_level = SandeshLevel.SYS_NOTICE
        logging_fun = log_fun if log_fun else sandesh.KubeManagerNoticeLog

        # Log to syslog.
        self.syslog(log_msg, log_level)

        # Log using the desired logging function.
        self.log(log_msg, level=log_level, fun=logging_fun)

    # INFO.
    def info(self, log_msg, log_fun=None):
        log_level = SandeshLevel.SYS_INFO
        logging_fun = log_fun if log_fun else sandesh.KubeManagerInfoLog

        # Log using the desired logging function.
        self.log(log_msg, level=log_level, fun=logging_fun)

    # DEBUG.
    def debug(self, log_msg, log_fun=None):
        log_level = SandeshLevel.SYS_DEBUG
        logging_fun = log_fun if log_fun else sandesh.KubeManagerDebugLog

        # Log using the desired logging function.
        self.log(log_msg, level=log_level, fun=logging_fun)

    def _redefine_sandesh_handles(self):
        """ Register custom introspect handlers. """
        # Register Pod DB introspect handler.
        introspect.PodDatabaseList.handle_request =\
            PodKM.sandesh_handle_db_list_request

        # Register Namespace DB introspect handler.
        introspect.NamespaceDatabaseList.handle_request =\
            NamespaceKM.sandesh_handle_db_list_request

        # Register Service DB introspect handler.
        introspect.ServiceDatabaseList.handle_request =\
            ServiceKM.sandesh_handle_db_list_request

        # Register NetworkPolicy DB introspect handler.
        introspect.NetworkPolicyDatabaseList.handle_request =\
            NetworkPolicyKM.sandesh_handle_db_list_request

        # Register Ingress DB introspect handler.
        introspect.IngressDatabaseList.handle_request =\
            IngressKM.sandesh_handle_db_list_request

    def sandesh_init(self):
        """ Init Sandesh """
        self._sandesh = Sandesh()

        # Register custom sandesh request handlers.
        self._redefine_sandesh_handles()

        # Initialize Sandesh generator.
        self._sandesh.init_generator(
            self._module["name"], self._module["hostname"],
            self._module["node_type_name"], self._module["instance_id"],
            self._args.random_collectors, 'kube_manager_context',
            int(self._args.http_server_port),
            ['cfgm_common', 'kube_manager'],
            logger_class=self._args.logger_class,
            logger_config_file=self._args.logging_conf,
            config=self._args.sandesh_config)

        # Set Sandesh logging params.
        self._sandesh.set_logging_params(
            enable_local_log=self._args.log_local,
            category=self._args.log_category, level=self._args.log_level,
            file=self._args.log_file, enable_syslog=self._args.use_syslog,
            syslog_facility=self._args.syslog_facility)

        # Connect to collector.
        ConnectionState.init(
            self._sandesh, self._module["hostname"], self._module["name"],
            self._module["instance_id"],
            staticmethod(ConnectionState.get_process_state_cb),
            NodeStatusUVE, NodeStatus, self._module["table"])

    def sandesh_uninit(self):
        self._sandesh.uninit()
开发者ID:cijohnson,项目名称:contrail-controller,代码行数:104,代码来源:logger.py


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