Browse Source

Fix module name in load_logging function

After refactoring the log function to tripleo-repos utils[1], the module
name 'tripleo-get-hash' become hardcoded in load_logging function.
Now, this function accepts the module name as parameter.

[1]: https://review.opendev.org/c/openstack/tripleo-repos/+/815991

Change-Id: I6840870cf5b55ee1d47e3634009f1c5ec7045b6f
Signed-off-by: Douglas Viroel <dviroel@redhat.com>
changes/87/817387/2
Douglas Viroel 6 months ago committed by Douglas Viroel
parent
commit
4012795760
  1. 2
      plugins/module_utils/tripleo_repos/get_hash/__main__.py
  2. 4
      plugins/module_utils/tripleo_repos/utils.py
  3. 2
      plugins/module_utils/tripleo_repos/yum_config/__main__.py

2
plugins/module_utils/tripleo_repos/get_hash/__main__.py

@ -32,7 +32,7 @@ def _validate_args(parsed_args):
def main():
load_logging()
load_logging(module_name="tripleo-get-hash")
config = TripleOHashInfo.load_config()
parser = argparse.ArgumentParser(description='tripleo-get-hash.py')
parser.add_argument(

4
plugins/module_utils/tripleo_repos/utils.py

@ -56,7 +56,7 @@ else:
return (str(e), -1)
def load_logging(level=logging.INFO):
def load_logging(level=logging.INFO, module_name="tripleo-repos"):
"""Load and set logging level. Default is set to logging.INFO level."""
logger = logging.getLogger()
# Only add logger once to avoid duplicated streams in tests
@ -73,7 +73,7 @@ def load_logging(level=logging.INFO):
if stdout_handlers == []:
formatter = logging.Formatter(
(
"%(asctime)s - tripleo-get-hash - %(levelname)s - "
"%(asctime)s - " + module_name + " - %(levelname)s - "
"%(message)s"
)
)

2
plugins/module_utils/tripleo_repos/yum_config/__main__.py

@ -38,7 +38,7 @@ def options_to_dict(options):
def main():
load_logging()
load_logging(module_name="tripleo-yum-config")
# Get release model and version
distro, major_version, __ = utils.get_distro_info()
py_version = sys.version_info.major

Loading…
Cancel
Save