Skip to content

Commit b83849b

Browse files
committed
a logging fix
1 parent e2b6897 commit b83849b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

custom_components/fordconnect_query/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ async def request_health(self):
517517
health_data = await self.__request_data(FORD_VEH_HEALTH_TEMP, "health")
518518
return health_data
519519

520-
async def __request_data(self, url_template:str, type:str):
520+
async def __request_data(self, url_template:str, logging_type:str):
521521
url = url_template.format(base_url=FORD_FCON_QUERY_BASE_URL)
522522
res = await self._session.async_request(
523523
method="get",
@@ -527,26 +527,26 @@ async def __request_data(self, url_template:str, type:str):
527527
res.raise_for_status()
528528
response_data = await res.json()
529529
if response_data is not None:
530-
_LOGGER.debug(f"{self.vli}request_{type}(): {len(response_data)} - {response_data.keys() if response_data is not None else 'None'}")
530+
_LOGGER.debug(f"{self.vli}request_{logging_type}(): {len(response_data)} - {response_data.keys() if response_data is not None else 'None'}")
531531
else:
532-
_LOGGER.debug(f"{self.vli}request_{type}(): No data received!")
532+
_LOGGER.debug(f"{self.vli}request_{logging_type}(): No data received!")
533533

534534
# dumping?
535535
if self._log_to_filesystem and response_data is not None:
536536
try:
537-
await asyncio.get_running_loop().run_in_executor(None, lambda: self.__dump_data(type, response_data))
538-
except BaseException as e:
539-
_LOGGER.debug(f"{self.vli}Error while dumping {type} data to file: {type(e).__name__} - {e}")
537+
await asyncio.get_running_loop().run_in_executor(None, lambda: self.__dump_data(logging_type, response_data))
538+
except BaseException as exc:
539+
_LOGGER.debug(f"{self.vli}Error while dumping {logging_type} data to file: {type(exc).__name__} - {exc}")
540540

541541
return response_data
542542

543-
except BaseException as e:
543+
except BaseException as exc:
544544
if res.status == 429:
545-
_LOGGER.debug(f"{self.vli}request_{type}():{url} caused {res.status} - rate limit exceeded - sleeping for 15 seconds")
545+
_LOGGER.debug(f"{self.vli}request_{logging_type}():{url} caused {res.status} - rate limit exceeded - sleeping for 15 seconds")
546546
self._last_update_time = time.monotonic()
547547
return RATE_LIMIT_INDICATOR
548548
else:
549-
_LOGGER.info(f"{self.vli}request_{type}():{url} caused {type(e).__name__} {e}")
549+
_LOGGER.info(f"{self.vli}request_{logging_type}():{url} caused {type(exc).__name__} {exc}")
550550
stack_trace = traceback.format_stack()
551551
stack_trace_str = ''.join(stack_trace[:-1]) # Exclude the call to this function
552552
_LOGGER.debug(f"{self.vli}stack trace (for marq24 to be able to debug):\n{stack_trace_str}")

0 commit comments

Comments
 (0)