Skip to content

Commit

Permalink
Each file has an independent logger, which includes their names
Browse files Browse the repository at this point in the history
  • Loading branch information
gabryelreyes committed Jun 20, 2024
1 parent 198fe9a commit 85c393d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/pyPolarionCli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
PROG_GITHUB = f"Find the project on GitHub: {__repository__}"
PROG_EPILOG = f"{PROG_COPYRIGHT} - {PROG_GITHUB}"

LOG: logging.Logger = logging.getLogger(__name__)

################################################################################
# Classes
################################################################################
Expand Down Expand Up @@ -145,9 +147,9 @@ def main() -> Ret:
# If the verbose flag is set, change the default logging level.
if args.verbose:
logging.basicConfig(level=logging.INFO)
logging.info("Program arguments: ")
LOG.info("Program arguments: ")
for arg in vars(args):
logging.info("* %s = %s", arg, vars(args)[arg])
LOG.info("* %s = %s", arg, vars(args)[arg])

# Create a Polarion client which communicates to the Polarion server.
# A broad exception has to be caught since the specific Exception Type can't be accessed.
Expand All @@ -158,7 +160,7 @@ def main() -> Ret:
verify_certificate=False,
static_service_list=True)
except Exception as e: # pylint: disable=broad-exception-caught
logging.error(e)
LOG.error(e)
ret_status = Ret.ERROR_LOGIN

if Ret.OK == ret_status:
Expand All @@ -174,7 +176,7 @@ def main() -> Ret:
if handler is not None:
ret_status = handler(args, client)
else:
logging.error("Command '%s' not found!", args.cmd)
LOG.error("Command '%s' not found!", args.cmd)
ret_status = Ret.ERROR_INVALID_ARGUMENTS

return ret_status
Expand Down
5 changes: 3 additions & 2 deletions src/pyPolarionCli/cmd_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
# Variables
################################################################################

LOG: logging.Logger = logging.getLogger(__name__)
_CMD_NAME = "search"
_OUTPUT_FILE_NAME = "search_results.json"

Expand Down Expand Up @@ -202,7 +203,7 @@ def _execute(args, polarion_client: Polarion) -> Ret:
output_dict['project'])
# Exception of type Exception is raised when the project does not exist.
except Exception as ex: # pylint: disable=broad-except
logging.error("%s", ex)
LOG.error("%s", ex)
ret_status = Ret.ERROR_SEARCH_FAILED
else:
# Search for work items in the project.
Expand Down Expand Up @@ -230,7 +231,7 @@ def _execute(args, polarion_client: Polarion) -> Ret:
with open(file_path, 'w', encoding="UTF-8") as file:
file.write(json.dumps(output_dict, indent=2))

logging.info("Search results stored in %s", file_path)
LOG.info("Search results stored in %s", file_path)
ret_status = Ret.OK

return ret_status
Expand Down

0 comments on commit 85c393d

Please sign in to comment.