algopy_testing.utilities.log
Module Contents
Section titled “Module Contents”Functions
Section titled “Functions”log(→ None) | Concatenates and logs supplied args as a single bytes value. |
|---|---|
logged_assert(→ None) | Asserts that a condition is true, logging a formatted error message before |
logged_err(→ None) | Logs a formatted error message and immediately fails the transaction. |
log(*args: UInt64 | Bytes | BytesBacked | str | bytes | int, sep: Bytes | bytes | str = b”) → None
Section titled “log(*args: UInt64 | Bytes | BytesBacked | str | bytes | int, sep: Bytes | bytes | str = b”) → None”Concatenates and logs supplied args as a single bytes value.
UInt64 args are converted to bytes and each argument is separated by sep. Literal str values will be encoded as UTF8.
logged_assert(condition: bool = None, /, error_code: LiteralString, error_message: LiteralString | None = None, prefix: Literal[‘AER’, ‘ERR’] = ‘ERR’) → None
Section titled “logged_assert(condition: bool = None, /, error_code: LiteralString, error_message: LiteralString | None = None, prefix: Literal[‘AER’, ‘ERR’] = ‘ERR’) → None”Asserts that a condition is true, logging a formatted error message before failing if the condition is false.
The logged output follows the format {prefix}:{error_code} or
{prefix}:{error_code}:{error_message} and is compatible with ARC-56 and ARC-32
clients.
Note this increases the generated bytecode, so keeping error_code and
error_message short is recommended.
- Parameters:
- condition – The condition to assert; if false, logs an error and fails.
- error_code – An alphanumeric error code. Must not contain
:. - error_message – Optional message appended after the code. Must not contain
:. - prefix – Error prefix, either
"AER"or"ERR".
logged_err(error_code: LiteralString, error_message: LiteralString | None = None, prefix: Literal[‘AER’, ‘ERR’] = ‘ERR’) → None
Section titled “logged_err(error_code: LiteralString, error_message: LiteralString | None = None, prefix: Literal[‘AER’, ‘ERR’] = ‘ERR’) → None”Logs a formatted error message and immediately fails the transaction.
Note this is equivalent to logged_assert(False, error_code, error_message, prefix). This function increases the generated bytecode, so keeping error_code
and error_message short is recommended.
The logged output follows the ARC-65 format {prefix}:{error_code} or
{prefix}:{error_code}:{error_message} and is compatible with ARC-56 and ARC-32
clients.
- Parameters:
- error_code – An alphanumeric error code. Must not contain
:. - error_message – Optional message appended after the code. Must not contain
:. - prefix – Error prefix, either
"AER"or"ERR".
- error_code – An alphanumeric error code. Must not contain