Skip to content

Commit 2c5575f

Browse files
committed
Improve error logging
1 parent 3ef155b commit 2c5575f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

seleniumbase/core/log_helper.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import codecs
23
import datetime
34
import os
@@ -39,11 +40,21 @@ def log_test_failure_data(test, test_logpath, driver, browser, url=None):
3940
utc_offset = -time.timezone / 3600.0
4041
utc_str = "UTC+0"
4142
if utc_offset > 0:
42-
utc_str = "UTC+%s" % utc_offset
43+
if utc_offset < 10:
44+
utc_str = "UTC+0%s" % utc_offset
45+
else:
46+
utc_str = "UTC+%s" % utc_offset
4347
elif utc_offset < 0:
44-
utc_str = "UTC%s" % utc_offset
48+
if utc_offset > -10:
49+
utc_str = "UTC-0%s" % abs(utc_offset)
50+
else:
51+
utc_str = "UTC-%s" % abs(utc_offset)
4552
utc_str = utc_str.replace('.5', '.3').replace('.', ':') + "0"
46-
time_zone = '(' + '/'.join(time.tzname) + ', ' + utc_str + ')'
53+
time_zone = ""
54+
try:
55+
time_zone = '(' + time.tzname[time.daylight] + ', ' + utc_str + ')'
56+
except Exception:
57+
time_zone = '(' + utc_str + ')'
4758
# Use [Day-of-Week, Month Day, Year] format when time zone < GMT/UTC-3
4859
the_date = now.strftime("%A, %B %d, %Y").replace(' 0', ' ')
4960
if utc_offset >= -3:

0 commit comments

Comments
 (0)