import xmlrpc.client

url = 'http://localhost:16001'
db = 'hazard_new'
username = 'admin'
password = '123'

try:
    common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
    uid = common.authenticate(db, username, 'admin', {})
    if not uid:
        uid = common.authenticate(db, 'admin', '123', {})
    
    models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
    
    logs = models.execute_kw(db, uid, 'admin', 'ir.logging', 'search_read', [[['message', 'ilike', 'Shopify']]], {'fields': ['create_date', 'name', 'level', 'message'], 'order': 'id desc', 'limit': 20})
    for l in logs:
        print(f"[{l['create_date']}] {l['level']} - {l['message']}")
except Exception as e:
    print("Error:", e)
