3 # jose.lausuch@ericsson.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
19 # import functest_logger as fl
20 # logger = fl.Logger("script_name").getLogger()
21 # logger.info("message to be shown with - INFO - ")
22 # logger.debug("message to be shown with - DEBUG -")
29 from functest.utils.constants import CONST
32 "stevedore.extension",
33 "keystoneauth.session",
34 "keystoneauth.identity.v3.base",
35 "novaclient.v2.client",
36 "neutronclient.v2_0.client",
37 "glanceclient.common.http",
38 "cinderclient.v2.client",
39 "cinderclient.client"]
46 def __new__(cls, logger_name):
47 if cls.instance is None:
48 cls.instance = object.__new__(cls)
51 def __init__(self, logger_name):
53 self.logger = logging.getLogger(logger_name)
54 for module_name in ignore:
55 logging.getLogger(module_name).setLevel(logging.WARNING)
61 if CONST.CI_DEBUG and CONST.CI_DEBUG.lower() == "true":
65 def setup_logging(self, default_path=CONST.dir_functest_logging_cfg,
66 default_level=logging.INFO,
69 value = os.getenv(env_key, None)
72 if os.path.exists(path):
73 with open(path, 'rt') as f:
75 if (config['handlers'] and
76 config['handlers']['console']):
77 stream_level = logging.INFO
79 stream_level = logging.DEBUG
80 config['handlers']['console']['level'] = stream_level
81 logging.config.dictConfig(config)
83 logging.basicConfig(level=default_level)