Replaced Logger usage with LOG_x (#548)

This commit is contained in:
Ken Van Hoeylandt
2026-07-04 23:49:19 +02:00
committed by GitHub
parent ecad2248d9
commit 9d5993930d
162 changed files with 1776 additions and 1842 deletions
+9 -9
View File
@@ -1,19 +1,19 @@
#include "Tactility/app/fileselection/State.h"
#include <Tactility/file/File.h>
#include <Tactility/Logger.h>
#include <Tactility/MountPoints.h>
#include <Tactility/kernel/Platform.h>
#include <Tactility/LogMessages.h>
#include <cstring>
#include <dirent.h>
#include <tactility/log.h>
#include <unistd.h>
#include <vector>
namespace tt::app::fileselection {
static const auto LOGGER = Logger("FileSelection");
constexpr auto* TAG = "FileSelection";
State::State() {
if (kernel::getPlatform() == kernel::PlatformSimulator) {
@@ -21,7 +21,7 @@ State::State() {
if (getcwd(cwd, sizeof(cwd)) != nullptr) {
setEntriesForPath(cwd);
} else {
LOGGER.error("Failed to get current work directory files");
LOG_E(TAG, "Failed to get current work directory files");
setEntriesForPath("/");
}
} else {
@@ -34,11 +34,11 @@ std::string State::getSelectedChildPath() const {
}
bool State::setEntriesForPath(const std::string& path) {
LOGGER.info("Changing path: {} -> {}", current_path, path);
LOG_I(TAG, "Changing path: %s -> %s", current_path.c_str(), path.c_str());
auto lock = mutex.asScopedLock();
if (!lock.lock(100)) {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "setEntriesForPath");
LOG_E(TAG, "Mutex acquisition timeout (%s)", "setEntriesForPath");
return false;
}
@@ -48,7 +48,7 @@ bool State::setEntriesForPath(const std::string& path) {
*/
bool show_custom_root = (kernel::getPlatform() == kernel::PlatformEsp) && (path == "/");
if (show_custom_root) {
LOGGER.info("Setting custom root");
LOG_I(TAG, "Setting custom root");
dir_entries = file::getFileSystemDirents();
current_path = path;
selected_child_entry = "";
@@ -57,12 +57,12 @@ bool State::setEntriesForPath(const std::string& path) {
dir_entries.clear();
int count = file::scandir(path, dir_entries, &file::direntFilterDotEntries, file::direntSortAlphaAndType);
if (count >= 0) {
LOGGER.info("{} has {} entries", path, count);
LOG_I(TAG, "%s has %d entries", path.c_str(), count);
current_path = path;
selected_child_entry = "";
return true;
} else {
LOGGER.error("Failed to fetch entries for {}", path);
LOG_E(TAG, "Failed to fetch entries for %s", path.c_str());
return false;
}
}
@@ -70,7 +70,7 @@ bool State::setEntriesForPath(const std::string& path) {
bool State::setEntriesForChildPath(const std::string& childPath) {
auto path = file::getChildPath(current_path, childPath);
LOGGER.info("Navigating from {} to {}", current_path, path);
LOG_I(TAG, "Navigating from %s to %s", current_path.c_str(), path.c_str());
return setEntriesForPath(path);
}
+12 -12
View File
@@ -1,15 +1,15 @@
#include <Tactility/app/fileselection/View.h>
#include <Tactility/LogMessages.h>
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h>
#include <Tactility/Tactility.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <tactility/check.h>
#include <Tactility/file/File.h>
#include <Tactility/kernel/Platform.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <tactility/check.h>
#include <tactility/log.h>
#include <cstring>
#include <unistd.h>
@@ -20,7 +20,7 @@
namespace tt::app::fileselection {
const static Logger LOGGER = Logger("FileSelection");
constexpr auto* TAG = "FileSelection";
// region Callbacks
@@ -47,11 +47,11 @@ void View::onTapFile(const std::string& path, const std::string& filename) {
if (kernel::getPlatform() == kernel::PlatformSimulator) {
char cwd[PATH_MAX];
if (getcwd(cwd, sizeof(cwd)) == nullptr) {
LOGGER.error("Failed to get current working directory");
LOG_E(TAG, "Failed to get current working directory");
return;
}
if (!file_path.starts_with(cwd)) {
LOGGER.error("Can only work with files in working directory {}", cwd);
LOG_E(TAG, "Can only work with files in working directory %s", cwd);
return;
}
processed_filepath = file_path.substr(strlen(cwd));
@@ -59,7 +59,7 @@ void View::onTapFile(const std::string& path, const std::string& filename) {
processed_filepath = file_path;
}
LOGGER.info("Clicked {}", processed_filepath);
LOG_I(TAG, "Clicked %s", processed_filepath.c_str());
lv_textarea_set_text(path_textarea, processed_filepath.c_str());
}
@@ -67,7 +67,7 @@ void View::onTapFile(const std::string& path, const std::string& filename) {
void View::onDirEntryPressed(uint32_t index) {
dirent dir_entry;
if (state->getDirent(index, dir_entry)) {
LOGGER.info("Pressed {} {}", dir_entry.d_name, dir_entry.d_type);
LOG_I(TAG, "Pressed %s %d", dir_entry.d_name, (int)dir_entry.d_type);
state->setSelectedChildEntry(dir_entry.d_name);
using namespace tt::file;
switch (dir_entry.d_type) {
@@ -78,7 +78,7 @@ void View::onDirEntryPressed(uint32_t index) {
update();
break;
case TT_DT_LNK:
LOGGER.warn("Opening links is not supported");
LOG_W(TAG, "Opening links is not supported");
break;
case TT_DT_REG:
onTapFile(state->getCurrentPath(), dir_entry.d_name);
@@ -96,7 +96,7 @@ void View::onSelectButtonPressed(lv_event_t* event) {
auto* view = static_cast<View*>(lv_event_get_user_data(event));
const char* path = lv_textarea_get_text(view->path_textarea);
if (path == nullptr || strlen(path) == 0) {
LOGGER.warn("Select pressed, but not path found in textarea");
LOG_W(TAG, "Select pressed, but not path found in textarea");
return;
}
@@ -140,7 +140,7 @@ void View::createDirEntryWidget(lv_obj_t* list, dirent& dir_entry) {
void View::onNavigateUpPressed() {
if (state->getCurrentPath() != "/") {
LOGGER.info("Navigating upwards");
LOG_I(TAG, "Navigating upwards");
std::string new_absolute_path;
if (string::getPathParent(state->getCurrentPath(), new_absolute_path)) {
state->setEntriesForPath(new_absolute_path);
@@ -161,7 +161,7 @@ void View::update() {
state->withEntries([this](const std::vector<dirent>& entries) {
for (auto entry : entries) {
LOGGER.debug("Entry: {} {}", entry.d_name, entry.d_type);
LOG_D(TAG, "Entry: %s %d", entry.d_name, (int)entry.d_type);
createDirEntryWidget(dir_entry_list, entry);
}
});
@@ -172,7 +172,7 @@ void View::update() {
lv_obj_remove_flag(navigate_up_button, LV_OBJ_FLAG_HIDDEN);
}
} else {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "lvgl");
LOG_E(TAG, "Mutex acquisition timeout (%s)", "lvgl");
}
}