[syslog] Keep the log level to severity table in flash (#20662)

This commit is contained in:
J. Nick Koston
2026-10-13 12:22:35 -10:00
committed by GitHub
parent a6dbd72c53
commit a0c7d754cb
+3 -2
View File
@@ -2,12 +2,13 @@
#include "esphome/components/logger/logger.h"
#include "esphome/core/application.h"
#include "esphome/core/hal.h"
#include "esphome/core/time.h"
namespace esphome::syslog {
// Map log levels to syslog severity using an array, indexed by ESPHome log level (1-7)
constexpr int LOG_LEVEL_TO_SYSLOG_SEVERITY[] = {
static constexpr uint8_t LOG_LEVEL_TO_SYSLOG_SEVERITY[] PROGMEM = {
3, // NONE
3, // ERROR
4, // WARN
@@ -35,7 +36,7 @@ void Syslog::log_(const int level, const char *tag, const char *message, size_t
// Syslog PRI calculation: facility * 8 + severity
int severity = 7;
if ((unsigned) level <= 7) {
severity = LOG_LEVEL_TO_SYSLOG_SEVERITY[level];
severity = progmem_read_byte(&LOG_LEVEL_TO_SYSLOG_SEVERITY[level]);
}
int pri = this->facility_ * 8 + severity;