Fix logger bug on Windows: path contains '\'. (#12197)

* Fix logger bug on Windows: path contains '\'.

* update

* Update __init__.py
This commit is contained in:
Boyi C 2018-02-07 04:56:31 +08:00 committed by Paulus Schoutsen
parent bd29cd2ba2
commit 7e246e4680

View file

@ -76,10 +76,11 @@ def _figure_out_source(record, call_stack, hass):
# Iterate through the stack call (in reverse) and find the last call from
# a file in Home Assistant. Try to figure out where error happened.
paths_re = r'(?:{})/(.*)'.format('|'.join([re.escape(x) for x in paths]))
for pathname in reversed(stack):
# Try to match with a file within Home Assistant
match = re.match(r'(?:{})/(.*)'.format('|'.join(paths)), pathname)
match = re.match(paths_re, pathname)
if match:
return match.group(1)
# Ok, we don't know what this is