1. from usr.bin.guard import GuardContext
    2. def net(*args, **kwargs):
    3. """网络回调函数"""
    4. app_log.debug("net_callback,args:{},kwargs:{}".format(args, kwargs))
    5. if __name__ == '__main__':
    6. # 初始化全局容器
    7. guard_context = GuardContext()
    8. guard_context.refresh()
    9. # 获取网络服务&日志服务
    10. net_service = guard_context.get_server('net')
    11. log_service = guard_context.get_server('log')
    12. # 订阅网络服务
    13. net_service.subscribe(net)
    14. # 获取app_log
    15. app_log = guard_context.get_logger("app_log")
    16. app_log.debug("net status: {}".format(net_service.get_net_status()))