#!/usr/bin/env python3 """ Script to replace all print statements with logging in uniswap_manager.py """ import re def replace_print_with_logging(file_path): """Replace print statements with logging calls""" with open(file_path, 'r') as f: content = f.read() # Replace print statements with appropriate logging levels replacements = [ # Error messages (r'print\(f"ERROR ([^"]+)"\)', r'logger.error(f"\1")'), (r'print\(f"ERROR ([^"]+)"\)', r'logger.error(f"\1")'), # Warning messages (r'print\(f"WARNING ([^"]+)"\)', r'logger.warning(f"\1")'), (r'print\(f"WARNING ([^"]+)"\)', r'logger.warning(f"\1")'), # Info messages (r'print\(f"([^(ERROR|WARNING)][^"]+)"\)', r'logger.info(f"\1")'), (r'print\(f"([^(ERROR|WARNING)][^"]+)"\)', r'logger.info(f"\1")'), # Simple print without f-string (r'print\("([^"]+)"\)', r'logger.info("\1")'), (r'print\("([^"]+)"\)', r'logger.info("\1")'), ] updated_content = content for pattern, replacement in replacements: updated_content = re.sub(pattern, replacement, updated_content) # Write back to file with open(file_path, 'w') as f: f.write(updated_content) print(f"✅ Updated logging in {file_path}") if __name__ == "__main__": file_path = "K:\\Projects\\hyper\\clp_auto_hedger\\uniswap_manager.py" replace_print_with_logging(file_path)