Skip to content

Latest commit

 

History

History
71 lines (52 loc) · 2.17 KB

logging.rst

File metadata and controls

71 lines (52 loc) · 2.17 KB

Logging

The pysui package has logging enabled. However; it is up to the application(s) using the SDK to setup logging configuration. If this is not done, pysui logging information is lost.

Module Logging

Select pysui modules are setup for logging and have the following construct:

logger = logging.getLogger("pysui.MODULE_NAME")
if not logging.getLogger().handlers:
    logger.addHandler(logging.NullHandler())
    logger.propagate = False

As you can see, if a root logger is not setup, pysui log messages go to the NullHandler (no-op)

With this construct, the root logger (in application) must be configured prior to the inclusion of pysui modules. For example:

import logging

logging.basicConfig(
    filename="myapplication.log",
    filemode="w",
    encoding="utf-8",
    format="%(asctime)s %(module)s %(levelname)s %(message)s",
    level=logging.DEBUG,
)

from pysui import SuiConfig, SyncClient

def main():
    """Main entry point for application."""
    client = SyncClient(SuiConfig.default_config())

    # etc.

if __name__ == "__main__":
    main()

Log Enabled Modules

Not every module in pysui is log enabled and adding logging and logging messages is an ongoing effort. The following have been enabled and have various degrees of logging messages:

Module
pysui.sui.sui_config
pysui.sui.sui_clients.sync_client
pysui.sui.sui_clients.async_client
pysui.sui.sui_clients.subscribe
pysui.sui.sui_txn.sync_transaction
pysui.sui.sui_txn.async_transaction
pysui.sui.sui_txn.transaction_builder