Add ISR logging failsafe

This commit is contained in:
Theo Arends 2024-01-30 16:57:45 +01:00
parent bfd44d06f9
commit 95b03592dc
1 changed files with 9 additions and 0 deletions

View File

@ -2570,6 +2570,15 @@ uint32_t HighestLogLevel() {
} }
void AddLog(uint32_t loglevel, PGM_P formatP, ...) { void AddLog(uint32_t loglevel, PGM_P formatP, ...) {
#ifdef ESP32
if (xPortInIsrContext()) {
// When called from an ISR, you should not send out logs.
// Allocating memory from within an ISR is a big no-no.
// Also long-time blocking like sending logs (especially to a syslog server)
// is also really not a good idea from an ISR call.
return;
}
#endif
uint32_t highest_loglevel = HighestLogLevel(); uint32_t highest_loglevel = HighestLogLevel();
// If no logging is requested then do not access heap to fight fragmentation // If no logging is requested then do not access heap to fight fragmentation