[SYS] Reduce Logs flash footprint (#2232)

By building only the log level required into LOG_LEVEL

Co-authored-by: Florian <1technophile@users.noreply.github.com>
This commit is contained in:
FlorianandFlorian authored and GitHub committed 2025-08-19 09:15:41 -05:00
1 parent 6e6b54b05e
commit 32174e37a5
52 files changed
+1187 -1136

No files matched your search

+9 -9
View File
@@ -51,14 +51,14 @@ extern void createDiscovery(const char* sensor_type,
const char* state_class, const char* state_off, const char* state_on, const char* enum_options, const char* command_template);
void setupZsensorDS1820() {
Log.trace(F("DS1820: configured pin: %d for 1-wire bus" CR), DS1820_OWBUS_GPIO);
THEENGS_LOG_TRACE(F("DS1820: configured pin: %d for 1-wire bus" CR), DS1820_OWBUS_GPIO);
ds1820.begin();
// Search the OneWire bus for all devices
uint8_t numDevicesOnBus = ds1820.getDeviceCount();
// locate device(s) on 1-wire bus
Log.notice(F("DS1820: Found %d devices" CR), numDevicesOnBus);
THEENGS_LOG_NOTICE(F("DS1820: Found %d devices" CR), numDevicesOnBus);
// Cycle though all of the devices on the OneWire bus
for (int deviceIndex = 0; deviceIndex < numDevicesOnBus && ds1820_count < OW_MAX_SENSORS; deviceIndex++) {
@@ -91,7 +91,7 @@ void setupZsensorDS1820() {
ds1820.setResolution(ds1820_address, DS1820_RESOLUTION);
}
ds1820_resolution[ds1820_count] = ds1820.getResolution(ds1820_address);
Log.trace(F("DS1820: Device %d, Type: %s, Address: %s, Resolution: %d" CR),
THEENGS_LOG_TRACE(F("DS1820: Device %d, Type: %s, Address: %s, Resolution: %d" CR),
ds1820_count,
(char*)ds1820_type[ds1820_count].c_str(),
(char*)ds1820_addr[ds1820_count].c_str(),
@@ -101,7 +101,7 @@ void setupZsensorDS1820() {
}
if (ds1820.getDS18Count() == 0) {
Log.error(F("DS1820: Failed to enumerate sensors on 1-wire bus. Check your GPIO assignment!" CR));
THEENGS_LOG_ERROR(F("DS1820: Failed to enumerate sensors on 1-wire bus. Check your GPIO assignment!" CR));
}
// make requestTemperatures() non-blocking
@@ -143,7 +143,7 @@ void MeasureDS1820Temp() {
// trigger temperature conversion some time before actually
// calling getTempC() to make reading temperatures non-blocking
if (!triggeredConversion && ((millis() - timeDS1820) > (DS1820_INTERVAL_SEC * 1000UL - DS1820_CONV_TIME))) {
Log.trace(F("DS1820: Trigger temperature conversion..." CR));
THEENGS_LOG_TRACE(F("DS1820: Trigger temperature conversion..." CR));
ds1820.requestTemperatures();
triggeredConversion = true;
} else if (triggeredConversion && ((millis() - timeDS1820) > DS1820_INTERVAL_SEC * 1000UL)) {
@@ -151,16 +151,16 @@ void MeasureDS1820Temp() {
triggeredConversion = false;
if (ds1820_count < 1) {
Log.error(F("DS1820: Failed to identify any temperature sensors on 1-wire bus during setup!" CR));
THEENGS_LOG_ERROR(F("DS1820: Failed to identify any temperature sensors on 1-wire bus during setup!" CR));
} else {
Log.trace(F("DS1820: Reading temperature(s) from %d sensor(s)..." CR), ds1820_count);
THEENGS_LOG_TRACE(F("DS1820: Reading temperature(s) from %d sensor(s)..." CR), ds1820_count);
StaticJsonDocument<JSON_MSG_BUFFER> DS1820dataBuffer;
JsonObject DS1820data = DS1820dataBuffer.to<JsonObject>();
for (uint8_t i = 0; i < ds1820_count; i++) {
current_temp[i] = round(ds1820.getTempC(ds1820_devices[i]) * 10) / 10.0;
if (current_temp[i] == -127) {
Log.error(F("DS1820: Device %s currently disconnected!" CR), (char*)ds1820_addr[i].c_str());
THEENGS_LOG_ERROR(F("DS1820: Device %s currently disconnected!" CR), (char*)ds1820_addr[i].c_str());
} else if (DS1820_ALWAYS || current_temp[i] != persisted_temp[i]) {
DS1820data["tempf"] = (float)DallasTemperature::toFahrenheit(current_temp[i]);
DS1820data["tempc"] = (float)current_temp[i];
@@ -176,7 +176,7 @@ void MeasureDS1820Temp() {
if (SYSConfig.powerMode > 0)
ready_to_sleep = true;
} else {
Log.trace(F("DS1820: Temperature for device %s didn't change, don't publish it." CR), (char*)ds1820_addr[i].c_str());
THEENGS_LOG_TRACE(F("DS1820: Temperature for device %s didn't change, don't publish it." CR), (char*)ds1820_addr[i].c_str());
}
persisted_temp[i] = current_temp[i];
}