from usr.bin.guard import GuardContext
def net(*args, **kwargs):
"""网络回调函数"""
app_log.debug("net_callback,args:{},kwargs:{}".format(args, kwargs))
if __name__ == '__main__':
# 初始化全局容器
guard_context = GuardContext()
guard_context.refresh()
# 获取网络服务&日志服务
net_service = guard_context.get_server('net')
log_service = guard_context.get_server('log')
# 订阅网络服务
net_service.subscribe(net)
# 获取app_log
app_log = guard_context.get_logger("app_log")
app_log.debug("net status: {}".format(net_service.get_net_status()))