brownie
brownie copied to clipboard
Turn off "Transaction Sent" logging
Overview
I would like to turn off the "Transaction Sent" log that gets printed to the console everytime a transaction is processed.
Specification
Ideally, this would be incorporated with the logging
built-in package, where I can specify a logging level that disables all printing.
Dependencies
None
You can use the built-in logging module.
`import logging
Configure the root logger
logging.basicConfig(level=logging.INFO) # Set the desired logging level
Get the logger for the Ethereum transaction module (replace 'eth_transaction' with the actual module name)
eth_transaction_logger = logging.getLogger('eth_transaction')
Set the log level for the Ethereum transaction logger to a higher level (e.g., WARNING) to suppress INFO messages
eth_transaction_logger.setLevel(logging.WARNING)
Example usage
def process_ethereum_transaction(): Your transaction processing logic here Log a transaction message (this will be suppressed if the log level is set to WARNING or higher) eth_transaction_logger.info('Transaction Sent')
Call your function to process Ethereum transactions
process_ethereum_transaction() `
When you call the process_ethereum_transaction function, the log message "Transaction Sent" will only be printed if the log level is set to INFO or lower. If you set it to WARNING or higher, the message will be suppressed.