Files

52 lines
1.7 KiB
Python

import subprocess
import time
import sys
import logging
logging.basicConfig(level=logging.INFO, format='%(message)s')
def test_logcat():
logging.info("=== BẮT ĐẦU THEO DÕI LOGCAT ZALO ===")
logging.info("1. Đang dọn dẹp log cũ (clear logcat)...")
subprocess.run("adb -s 192.168.1.193:5555 shell logcat -c", shell=True)
logging.info("2. Đang lắng nghe log mới (Giới hạn trong 15 giây)...")
logging.info(">>> BẠN HÃY LẤY MÁY KHÁC NHẮN 1 TIN VÀO GROUP ZALO NGAY BÂY GIỜ NHÉ! <<<")
logging.info("-" * 50)
# Mở tiến trình logcat, lọc các log liên quan đến zalo hoặc notification
process = subprocess.Popen(
"adb -s 192.168.1.193:5555 shell logcat | grep -iE 'zalo|notification'",
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
encoding='utf-8',
errors='replace'
)
start_time = time.time()
try:
while time.time() - start_time < 15: # Lắng nghe trong 15 giây
if process.poll() is not None:
break
line = process.stdout.readline()
if line:
# Bỏ qua các log rác quá nhiều
if "memtrack" not in line.lower() and "perf" not in line.lower():
print(line.strip())
else:
time.sleep(0.1)
except KeyboardInterrupt:
pass
finally:
process.terminate()
logging.info("-" * 50)
logging.info("=== KẾT THÚC THEO DÕI ===")
logging.info("Bạn có thấy nội dung tin nhắn bạn vừa gửi xuất hiện trong đống log ở trên không?")
if __name__ == "__main__":
test_logcat()