diff --git a/stockcli/cli.py b/stockcli/cli.py --- a/stockcli/cli.py +++ b/stockcli/cli.py @@ -1,4 +1,5 @@ import json +import logging import logging.config from operator import itemgetter @@ -62,6 +63,7 @@ def stockcli(ctx: click.Context, configf choice = prompt.ask( "Enter a number to select a task", choices=list(TASK_MAP.keys()) ) + logging.debug(f"User selected task: {choice}") selected_task = TASK_MAP[choice][1] rerun = True diff --git a/stockcli/stock.py b/stockcli/stock.py --- a/stockcli/stock.py +++ b/stockcli/stock.py @@ -1,3 +1,4 @@ +import logging from operator import itemgetter from typing import Any @@ -130,6 +131,7 @@ def transfer_by_barcode(barcode: str) -> ) if not from_id: + logging.debug("User aborted task!") return grid = Table.grid(padding=DEFAULT_PADDING) @@ -159,11 +161,13 @@ def transfer_by_barcode(barcode: str) -> ) if not to_id: + logging.debug("User aborted task!") return amount = int_prompt.ask("Amount (Enter 0 to abort)") if not amount: + logging.debug("User aborted task!") return data = {"amount": amount, "location_id_from": from_id, "location_id_to": to_id} @@ -200,6 +204,7 @@ def add_by_barcode(barcode: str) -> None amount = int_prompt.ask("Amount (Enter 0 to abort)") if not amount: + logging.debug("User aborted task!") return data = {"amount": amount, "transaction_type": "purchase"} @@ -238,6 +243,7 @@ def update_by_barcode(barcode: str) -> N amount = int_prompt.ask("Amount (Enter 0 to abort)") if not amount: + logging.debug("User aborted task!") return data = { diff --git a/stockcli/utils.py b/stockcli/utils.py --- a/stockcli/utils.py +++ b/stockcli/utils.py @@ -21,8 +21,12 @@ def make_request(method: str, url_path: try: if data is not None: + logging.debug( + f"Making {method.upper()} request: {requested_url} with {data}" + ) response = method_function(session)(requested_url, json=data) else: + logging.debug(f"Making {method.upper()} request: {requested_url}") response = method_function(session)(requested_url) response.raise_for_status() except requests.Timeout: