def setup_logging(args): """ Configure logging. """ log_level = logging.INFO # get loglevel from environment or --loglevel log_level_str = os.environ.get("LOGLEVEL", "INFO") if args.log_level: # overwrite if present log_level_str = args.log_level # parse log_level_str = str(log_level_str).lower() if log_level_str == "debug": log_level = logging.DEBUG elif log_level_str == "info": log_level = logging.INFO elif log_level_str == "warning": log_level = logging.WARNING elif log_level_str == "error": log_level = logging.ERROR else: print("Loglevel '{}' unknown.".format(log_level_str)) # if "-v" is there set to debug if args.verbose: log_level = logging.DEBUG # select logging mode log_json = os.environ.get("LOGJSON", args.logjson) # configure all TangoLoggers TangoLogger.reconfigure_all_tango_loggers(log_level=log_level, log_json=log_json)
# # This work has also been performed in the framework of the 5GTANGO project, # funded by the European Commission under Grant number 761493 through # the Horizon 2020 and 5G-PPP programmes. The authors would like to # acknowledge the contributions of their colleagues of the SONATA # partner consortium (www.5gtango.eu). import argparse import os import sys from tngsdk.package.packager import PM from tngsdk.package.storage.tngcat import TangoCatalogBackend from tngsdk.package.storage.tngprj import TangoProjectFilesystemBackend from tngsdk.package.storage.osmnbi import OsmNbiBackend from tngsdk.package.logger import TangoLogger LOG = TangoLogger.getLogger(__name__) DEFAULT_WORKSPACE_DIR = os.path.join(os.path.expanduser("~"), ".tng-workspace") def dispatch(args): # trigger pack/unpack if args.package: # instantiate packager p = PM.new_packager(args, pkg_format=args.pkg_format) p.package() LOG.debug("Packager result: {}".format(p.result)) display_result_package(args, p.result) elif args.unpackage: # select and instantiate storage backend # default in CLI mode: TangoProjectFilesystemBackend
# acknowledge the contributions of their colleagues of the SONATA # partner consortium (www.sonata-nfv.eu). # # This work has also been performed in the framework of the 5GTANGO project, # funded by the European Commission under Grant number 761493 through # the Horizon 2020 and 5G-PPP programmes. The authors would like to # acknowledge the contributions of their colleagues of the SONATA # partner consortium (www.5gtango.eu). import logging import os from tngsdk.package import rest, cli from tngsdk.package.logger import TangoLogger # need to use __file__ in __init__.py to avoid dupl. logs LOG = TangoLogger.getLogger(os.path.basename(__file__)) def setup_logging(args): """ Configure logging. """ log_level = logging.INFO # get loglevel from environment or --loglevel log_level_str = os.environ.get("LOGLEVEL", "INFO") if args.log_level: # overwrite if present log_level_str = args.log_level # parse log_level_str = str(log_level_str).lower() if log_level_str == "debug": log_level = logging.DEBUG