Skip to content

Commit

Permalink
update logging logic
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmay-browserstack committed Sep 25, 2024
1 parent 93a36b9 commit dcf97c3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions percy/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
eligible_widths = {}

def log(message, lvl = 'info'):
message = f'{LABEL} {message}'
try:
requests.post(f'{PERCY_CLI_API}/percy/log',
json={'message': message, 'level': lvl}, timeout=1)
Expand Down Expand Up @@ -186,8 +187,8 @@ def percy_snapshot(driver, name, **kwargs):
if not data['success']: raise Exception(data['error'])
return data.get("data", None)
except Exception as e:
log(f'{LABEL} Could not take DOM snapshot "{name}"')
log(f'{LABEL} {e}')
log(f'Could not take DOM snapshot "{name}"')
log(f'{e}')
return None

# Take screenshot on driver
Expand Down Expand Up @@ -243,8 +244,8 @@ def percy_automate_screenshot(driver, name, options = None, **kwargs):
if not data['success']: raise Exception(data['error'])
return data.get("data", None)
except Exception as e:
log(f'{LABEL} Could not take Screenshot "{name}"')
log(f'{LABEL} {e}')
log(f'Could not take Screenshot "{name}"')
log(f'{e}')
return None

def get_element_ids(elements):
Expand Down

0 comments on commit dcf97c3

Please sign in to comment.