Skip to content

Avoid flooding the logger with ~500 errors when they are the same #1125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions can/interfaces/ics_neovi/neovi_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import logging
import os
import tempfile
from collections import deque, defaultdict
from collections import deque, defaultdict, Counter
from itertools import cycle
from threading import Event
from warnings import warn
Expand Down Expand Up @@ -89,7 +89,7 @@ def __init__(
severity: int,
restart_needed: int,
):
super().__init__(f"{description_short} {description_long}", error_code)
super().__init__(f"{description_short}. {description_long}", error_code)
self.description_short = description_short
self.description_long = description_long
self.severity = severity
Expand Down Expand Up @@ -319,9 +319,12 @@ def _process_msg_queue(self, timeout=0.1):
if errors:
logger.warning("%d error(s) found", errors)

for msg in ics.get_error_messages(self.dev):
error = ICSOperationError(*msg)
logger.warning(error)
for msg, count in Counter(ics.get_error_messages(self.dev)).items():
error = ICSApiError(*msg)
if count > 1:
logger.warning(f"{error} (Repeated {count} times)")
else:
logger.warning(error)

def _get_timestamp_for_msg(self, ics_msg):
if self._use_system_timestamp:
Expand Down