From 9b496587deb5f3f6be7f7d5aef3c0b9d4db95d86 Mon Sep 17 00:00:00 2001 From: khushal Date: Wed, 4 Dec 2024 18:35:00 +0530 Subject: [PATCH] (20241204) Some debugging facilities added in both SMS modules. --- utils_v2/sms/nimbus/async_nimbus.py | 17 ++++++++++++++++- .../sms/savvy_bulk_sms/async_savvy_bulk_sms.py | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/utils_v2/sms/nimbus/async_nimbus.py b/utils_v2/sms/nimbus/async_nimbus.py index 58d1a78..a1feeac 100644 --- a/utils_v2/sms/nimbus/async_nimbus.py +++ b/utils_v2/sms/nimbus/async_nimbus.py @@ -90,7 +90,8 @@ class AsyncNimbusSMS: api_key, http_client: httpx.AsyncClient = None, debug = True, - debug_prefix = "Nimbus SMS | " + debug_prefix = "Nimbus SMS | ", + debug_only_errors = True ): """ @@ -103,11 +104,13 @@ class AsyncNimbusSMS: internally. It is recommended that, for multi-auth use cases, you provide a common HTTP client from outside. :param debug: Whether, or not, you would like to show debugging messages (can be changed on the fly). :param debug_prefix: The prefix text to show with the debug string. + :param debug_only_errors: Whether you would like to show all debugging messages or just error messages. """ # Create the debugging tools: self.__printer = IceCreamDebugger(prefix = debug_prefix, includeContext = True) if not debug: self.__printer.disable() + self.__debug_only_errors = debug_only_errors # Accept/create an HTTP client to work with: if http_client: self.__http_client = http_client @@ -130,6 +133,18 @@ class AsyncNimbusSMS: self.__user_id = user_id, self.__api_key = api_key + def enable_debug(self): + self.__printer.enable() + + def disable_debug(self): + self.__printer.disable() + + def debug_only_errors(self): + self.__debug_only_errors = True + + def debug_everything(self): + self.__debug_only_errors = False + async def get_balance(self): """ diff --git a/utils_v2/sms/savvy_bulk_sms/async_savvy_bulk_sms.py b/utils_v2/sms/savvy_bulk_sms/async_savvy_bulk_sms.py index c2ad78e..2cf25e2 100644 --- a/utils_v2/sms/savvy_bulk_sms/async_savvy_bulk_sms.py +++ b/utils_v2/sms/savvy_bulk_sms/async_savvy_bulk_sms.py @@ -82,7 +82,8 @@ class AsyncSavvyBulkSMS: short_code: str, http_client: httpx.AsyncClient = None, debug = True, - debug_prefix = "Savvy SMS | " + debug_prefix = "Savvy SMS | ", + debug_only_errors = True ): """ @@ -92,11 +93,13 @@ class AsyncSavvyBulkSMS: :param short_code: Your short code with Savvy Bulk SMS. :param debug: Whether, or not, you would like to show debugging messages (can be changed on the fly). :param debug_prefix: The prefix text to show with the debug string. + :param debug_only_errors: Whether you would like to show all debugging messages or just error messages. """ # Create the debugging tools: self.__printer = IceCreamDebugger(prefix = debug_prefix, includeContext = True) if not debug: self.__printer.disable() + self.__debug_only_errors = debug_only_errors # Accept/create an HTTP client to work with: if http_client: self.__http_client = http_client @@ -118,6 +121,18 @@ class AsyncSavvyBulkSMS: self.__partner_id = partner_id self.__short_code = short_code + def enable_debug(self): + self.__printer.enable() + + def disable_debug(self): + self.__printer.disable() + + def debug_only_errors(self): + self.__debug_only_errors = True + + def debug_everything(self): + self.__debug_only_errors = False + async def send_sms( self, recipient_number,