Use ESP Logging Macros for i18n

This commit is contained in:
Thomas Basler
2025-04-18 18:09:34 +02:00
parent c5e97a5c7b
commit 7df4bbc454

View File

@@ -1,14 +1,16 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* Copyright (C) 2024 Thomas Basler and others * Copyright (C) 2024-2025 Thomas Basler and others
*/ */
#include "I18n.h" #include "I18n.h"
#include "MessageOutput.h"
#include "Utils.h" #include "Utils.h"
#include "defaults.h" #include "defaults.h"
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <LittleFS.h> #include <LittleFS.h>
#undef TAG
static const char* TAG = "i18n";
I18nClass I18n; I18nClass I18n;
I18nClass::I18nClass() I18nClass::I18nClass()
@@ -61,7 +63,7 @@ void I18nClass::readDisplayStrings(
// Deserialize the JSON document // Deserialize the JSON document
const DeserializationError error = deserializeJson(doc, f, DeserializationOption::Filter(filter)); const DeserializationError error = deserializeJson(doc, f, DeserializationOption::Filter(filter));
if (error) { if (error) {
MessageOutput.printf("Failed to read file %s\n", filename.c_str()); ESP_LOGE(TAG, "Failed to read file %s", filename.c_str());
f.close(); f.close();
return; return;
} }
@@ -114,7 +116,7 @@ void I18nClass::readLangPacks()
while (file != "") { while (file != "") {
if (file.endsWith(LANG_PACK_SUFFIX)) { if (file.endsWith(LANG_PACK_SUFFIX)) {
MessageOutput.printf("Read File %s\n", file.c_str()); ESP_LOGI(TAG, "Read File %s", file.c_str());
readConfig(file); readConfig(file);
} }
file = root.getNextFileName(); file = root.getNextFileName();
@@ -134,7 +136,7 @@ void I18nClass::readConfig(String file)
// Deserialize the JSON document // Deserialize the JSON document
const DeserializationError error = deserializeJson(doc, f, DeserializationOption::Filter(filter)); const DeserializationError error = deserializeJson(doc, f, DeserializationOption::Filter(filter));
if (error) { if (error) {
MessageOutput.printf("Failed to read file %s\n", file.c_str()); ESP_LOGE(TAG, "Failed to read file %s", file.c_str());
f.close(); f.close();
return; return;
} }
@@ -151,7 +153,7 @@ void I18nClass::readConfig(String file)
if (lang.code != "" && lang.name != "") { if (lang.code != "" && lang.name != "") {
_availLanguages.push_back(lang); _availLanguages.push_back(lang);
} else { } else {
MessageOutput.printf("Invalid meta data\n"); ESP_LOGE(TAG, "Invalid meta data");
} }
f.close(); f.close();