Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State logger #352

Merged
merged 2 commits into from
Jun 1, 2024
Merged

State logger #352

merged 2 commits into from
Jun 1, 2024

Conversation

cffls
Copy link
Collaborator

@cffls cffls commented May 26, 2024

Logs the state of an instance, e.g. txbuilder, when an exception is raised. Optionally, the state could be logged every time when the function is called if log level of the parent logger is set to DEBUG.

State logger is added to TransactionBuilder.build(), TransactionBuilder.build_and_sign(), ChainContext.submit_tx().

Sample log output:

2024-05-26 13:29:49,568 - PyCardano - WARNING - Class: <class 'pycardano.txbuilder.TransactionBuilder'>, method: <function TransactionBuilder.build at 0x104ef0e00>, state:
 {
  '_datums': {},
  '_excluded_inputs': [],
  '_input_addresses': [
    'addr_test1vrm9x2zsux7va6w892g38tvchnzahvcd9tykqf3ygnmwtaqyfg52x',
  ],
  '_inputs': [],
  '_inputs_to_redeemers': {},
  '_inputs_to_scripts': {},
  '_minting_script_to_redeemers': [],
  '_outputs': [
    {
      'address': addr_test1vrm9x2zsux7va6w892g38tvchnzahvcd9tykqf3ygnmwtaqyfg52x,
      'amount': {'coin': 1000000000, 'multi_asset': {}},
      'datum': None,
      'datum_hash': None,
      'post_alonzo': False,
      'script': None,
    },
    {
      'address': addr_test1vrm9x2zsux7va6w892g38tvchnzahvcd9tykqf3ygnmwtaqyfg52x,
      'amount': {
        'coin': 2000000,
        'multi_asset': {ScriptHash(hex='31313131313131313131313131313131313131313131313131313131'): {AssetName(b'NewToken'): 1}},
      },
      'datum': None,
      'datum_hash': None,
      'post_alonzo': False,
      'script': None,
    },
  ],
  '_potential_inputs': [],
  '_reference_scripts': [],
  '_withdrawal_script_to_redeemers': [],
  'auxiliary_data': None,
  'certificates': None,
  'collaterals': [],
  'context': <test.pycardano.util.FixedChainContext object at 0x10501d790>,
  'execution_memory_buffer': 0.2,
  'execution_step_buffer': 0.2,
  'fee_buffer': None,
  'initial_stake_pool_registration': False,
  'mint': None,
  'native_scripts': None,
  'reference_inputs': set(),
  'required_signers': None,
  'ttl': None,
  'utxo_selectors': [
    <pycardano.coinselection.RandomImproveMultiAsset object at 0x10501ccd0>,
    <pycardano.coinselection.LargestFirstSelector object at 0x10501cb50>,
  ],
  'validity_start': None,
  'withdrawals': None,
  'witness_override': None,
}

Logs the state of an instance, e.g. txbuilder, when an exception is raised. Optionally, the state could be logged every time when the function is called if log level of the parent logger is set to DEBUG.

State logger is added to `TransactionBuilder.build()`, `TransactionBuilder.build_and_sign()`, `ChainContext.submit_tx()`.
Copy link

codecov bot commented May 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.66%. Comparing base (20e8ed7) to head (b8b1576).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #352      +/-   ##
==========================================
+ Coverage   83.61%   83.66%   +0.05%     
==========================================
  Files          29       29              
  Lines        3722     3735      +13     
  Branches      939      942       +3     
==========================================
+ Hits         3112     3125      +13     
  Misses        445      445              
  Partials      165      165              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cffls cffls requested a review from a team May 26, 2024 20:33
@cffls cffls merged commit f50a955 into Python-Cardano:main Jun 1, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant