(20241204) Some debugging facilities added in both SMS modules.

This commit is contained in:
2024-12-04 18:35:00 +05:30
parent 7d5acfbd0d
commit 9b496587de
2 changed files with 32 additions and 2 deletions
+16 -1
View File
@@ -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):
"""