ist there any best practice for logging in rules? In my understanding openHAB offers four levels of logging with appropriate functions:
logError - Log an error that occurred during the execution of a rule. This might be a catched exception. Main idea is that the rule cannot finish successfully.
logWarn - Log a warning that something is wrong, but can be fixed by the programming of the rule. That is maybe that a NULL value is replaced by a default value.
logInfo - Log a simple information about something that might be interesting to the user in the log if the system works under normal condition. This might be the information that a specific state is reached or something has happend.
logDebug - Log an information that is as much helpfull in the case of debugging. This covers everything from simple checkmarks up to detailed information about variables etc.
If this is a more or less common understanding the next question is when to include which kind of logging in a rule.
- Report every exception caught as a logError
- Report every used default value as a LogWarn
- Report every not expected NULL value as a logWarn
- Add an info log entry every time required to show that normal operation is performed.
- Enclose every functional block in a rules with logDebug. One for the entry with a short description and values that are transported into the functional block. A log entry second if the functional block is finished with the values that are produced by the block
I have not used this scheme in my rules so far, so please feel free to add you best practice.