mirror of
https://github.com/esphome/esphome.git
synced 2026-10-14 02:02:51 +00:00
[syslog] Keep the log level to severity table in flash (#20662)
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user