(20241204) Some debugging facilities added in both SMS modules.
This commit is contained in:
@@ -90,7 +90,8 @@ class AsyncNimbusSMS:
|
|||||||
api_key,
|
api_key,
|
||||||
http_client: httpx.AsyncClient = None,
|
http_client: httpx.AsyncClient = None,
|
||||||
debug = True,
|
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.
|
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: 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_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:
|
# Create the debugging tools:
|
||||||
self.__printer = IceCreamDebugger(prefix = debug_prefix, includeContext = True)
|
self.__printer = IceCreamDebugger(prefix = debug_prefix, includeContext = True)
|
||||||
if not debug: self.__printer.disable()
|
if not debug: self.__printer.disable()
|
||||||
|
self.__debug_only_errors = debug_only_errors
|
||||||
|
|
||||||
# Accept/create an HTTP client to work with:
|
# Accept/create an HTTP client to work with:
|
||||||
if http_client: self.__http_client = http_client
|
if http_client: self.__http_client = http_client
|
||||||
@@ -130,6 +133,18 @@ class AsyncNimbusSMS:
|
|||||||
self.__user_id = user_id,
|
self.__user_id = user_id,
|
||||||
self.__api_key = api_key
|
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):
|
async def get_balance(self):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -82,7 +82,8 @@ class AsyncSavvyBulkSMS:
|
|||||||
short_code: str,
|
short_code: str,
|
||||||
http_client: httpx.AsyncClient = None,
|
http_client: httpx.AsyncClient = None,
|
||||||
debug = True,
|
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 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: 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_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:
|
# Create the debugging tools:
|
||||||
self.__printer = IceCreamDebugger(prefix = debug_prefix, includeContext = True)
|
self.__printer = IceCreamDebugger(prefix = debug_prefix, includeContext = True)
|
||||||
if not debug: self.__printer.disable()
|
if not debug: self.__printer.disable()
|
||||||
|
self.__debug_only_errors = debug_only_errors
|
||||||
|
|
||||||
# Accept/create an HTTP client to work with:
|
# Accept/create an HTTP client to work with:
|
||||||
if http_client: self.__http_client = http_client
|
if http_client: self.__http_client = http_client
|
||||||
@@ -118,6 +121,18 @@ class AsyncSavvyBulkSMS:
|
|||||||
self.__partner_id = partner_id
|
self.__partner_id = partner_id
|
||||||
self.__short_code = short_code
|
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(
|
async def send_sms(
|
||||||
self,
|
self,
|
||||||
recipient_number,
|
recipient_number,
|
||||||
|
|||||||
Reference in New Issue
Block a user