Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Patch Logger to reduce repeated messages frequency #122

Closed
wants to merge 1 commit into from

Conversation

krahabb
Copy link

@krahabb krahabb commented Feb 6, 2023

Hello Hans,
Sorry for this 'unsolicited' PR but I wanted to submit you a proposal for reducing the frequency of the integration logs which lead my working HA to some stressful situations (I have logging in ramdisk on my pi - so blame on me for that :)
This happened sometimes when the Viessmann api was unavailable for many hours and my HA log got overwhelmed. I saw other complaints about this on HA forums too and I've decided to share with you my idea about the matter without opening an issue but directly here:

This patch basically sets a timeout (fixed in code but customizable 'per call') where a logged message doesnt get repeated until the timeout elapses. The idea is that once you know something wrong is happening there's no need to repeat this on every entity update cycle or so since the situation is likely stalling somewehere else and there's no actual solution (As stated before this happened a couple of time when the Viessmann api went offline for a long time)

The logic for 'gating' each message is handled in the patched Logger class (hidden behind _Logger in the added module helpers.py)

There's another issue in my opinion in the fact the entity update code is not totally tryed/catched so it happens sometimes some exceptions pop up in the runner and this starts an annoying stack dump also impairing the HA log readability. I'm thinking about a general catcher which just logs the error message in normal circumstances and eventually sets the stack trace only when logging is configured for DEBUG
I'm working on a separate PR for this which I should be able to deliver in 1 or 2 days so to share the ideas

@oischinger
Copy link
Owner

Hey, thanks for the contribution.
I believe however that this will get rejected from HA Core. They will ask to "properly" fix that by handling exceptions correctly etc. Basically what you already proposed via #123
I think we should work on this one instead of working around the improperly handled exceptions.

Other than that you can always get rid of some logs of a specific component via yaml:

# Example configuration.yaml entry
logger:
  default: info
  logs:
    homeassistant.components.vicare: critical

@oischinger oischinger closed this Feb 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants