From 7e246e4680d71fe9913678ede731e8c6b51aa7ae Mon Sep 17 00:00:00 2001 From: Boyi C Date: Wed, 7 Feb 2018 04:56:31 +0800 Subject: [PATCH] Fix logger bug on Windows: path contains '\'. (#12197) * Fix logger bug on Windows: path contains '\'. * update * Update __init__.py --- homeassistant/components/system_log/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/system_log/__init__.py b/homeassistant/components/system_log/__init__.py index 7d9ebe85130..1dad1f3a1eb 100644 --- a/homeassistant/components/system_log/__init__.py +++ b/homeassistant/components/system_log/__init__.py @@ -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