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
+22 -21
View File
@@ -3,9 +3,8 @@
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/AppRegistration.h>
#include <Tactility/DispatcherThread.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/DispatcherThread.h>
#include <Tactility/service/ServiceManifest.h>
#include <Tactility/service/ServiceRegistration.h>
@@ -16,9 +15,11 @@
#include <utility>
#endif
#include <tactility/log.h>
namespace tt::service::loader {
static const auto LOGGER = Logger("Loader");
constexpr auto* TAG = "Loader";
constexpr auto LOADER_TIMEOUT = (100 / portTICK_PERIOD_MS);
@@ -44,17 +45,17 @@ static const char* appStateToString(app::State state) {
}
void LoaderService::onStartAppMessage(const std::string& id, app::LaunchId launchId, std::shared_ptr<const Bundle> parameters) {
LOGGER.info("Start by id {}", id);
LOG_I(TAG, "Start by id %s", id.c_str());
auto app_manifest = app::findAppManifestById(id);
if (app_manifest == nullptr) {
LOGGER.error("App not found: {}", id);
LOG_E(TAG, "App not found: %s", id.c_str());
return;
}
auto lock = mutex.asScopedLock();
if (!lock.lock(LOADER_TIMEOUT)) {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED);
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED);
return;
}
@@ -76,14 +77,14 @@ void LoaderService::onStartAppMessage(const std::string& id, app::LaunchId launc
void LoaderService::onStopTopAppMessage(const std::string& id) {
auto lock = mutex.asScopedLock();
if (!lock.lock(LOADER_TIMEOUT)) {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED);
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED);
return;
}
size_t original_stack_size = appStack.size();
if (original_stack_size == 0) {
LOGGER.error("Stop app: no app running");
LOG_E(TAG, "Stop app: no app running");
return;
}
@@ -91,12 +92,12 @@ void LoaderService::onStopTopAppMessage(const std::string& id) {
auto app_to_stop = appStack[appStack.size() - 1];
if (app_to_stop->getManifest().appId != id) {
LOGGER.error("Stop app: id mismatch (wanted {} but found {} on top of stack)", id, app_to_stop->getManifest().appId);
LOG_E(TAG, "Stop app: id mismatch (wanted %s but found %s on top of stack)", id.c_str(), app_to_stop->getManifest().appId.c_str());
return;
}
if (original_stack_size == 1 && app_to_stop->getManifest().appName != "Boot") {
LOGGER.error("Stop app: can't stop root app");
LOG_E(TAG, "Stop app: can't stop root app");
return;
}
@@ -116,16 +117,16 @@ void LoaderService::onStopTopAppMessage(const std::string& id) {
// We only expect the app to be referenced within the current scope
if (app_to_stop.use_count() > 1) {
LOGGER.warn("Memory leak: Stopped {}, but use count is {}", app_to_stop->getManifest().appId, app_to_stop.use_count() - 1);
LOG_W(TAG, "Memory leak: Stopped %s, but use count is %d", app_to_stop->getManifest().appId.c_str(), (int)(app_to_stop.use_count() - 1));
}
// Refcount is expected to be 2: 1 within app_to_stop and 1 within the current scope
if (app_to_stop->getApp().use_count() > 2) {
LOGGER.warn("Memory leak: Stopped {}, but use count is {}", app_to_stop->getManifest().appId, app_to_stop->getApp().use_count() - 2);
LOG_W(TAG, "Memory leak: Stopped %s, but use count is %d", app_to_stop->getManifest().appId.c_str(), (int)(app_to_stop->getApp().use_count() - 2));
}
#ifdef ESP_PLATFORM
LOGGER.info("Free heap: {}", heap_caps_get_free_size(MALLOC_CAP_INTERNAL));
LOG_I(TAG, "Free heap: %d", (int)heap_caps_get_free_size(MALLOC_CAP_INTERNAL));
#endif
std::shared_ptr<app::AppInstance> instance_to_resume;
@@ -182,18 +183,18 @@ int LoaderService::findAppInStack(const std::string& id) const {
void LoaderService::onStopAllAppMessage(const std::string& id) {
auto lock = mutex.asScopedLock();
if (!lock.lock(LOADER_TIMEOUT)) {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED);
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED);
return;
}
if (!isRunning(id)) {
LOGGER.error("Stop all: {} not running", id);
LOG_E(TAG, "Stop all: %s not running", id.c_str());
return;
}
int app_to_stop_index = findAppInStack(id);
if (app_to_stop_index < 0) {
LOGGER.error("Stop all: {} not found in stack", id);
LOG_E(TAG, "Stop all: %s not found in stack", id.c_str());
return;
}
@@ -220,7 +221,7 @@ void LoaderService::onStopAllAppMessage(const std::string& id) {
}
if (instance_to_resume != nullptr) {
LOGGER.info("Resuming {}", instance_to_resume->getManifest().appId);
LOG_I(TAG, "Resuming %s", instance_to_resume->getManifest().appId.c_str());
transitionAppToState(instance_to_resume, app::State::Showing);
instance_to_resume->getApp()->onResult(
@@ -236,8 +237,8 @@ void LoaderService::transitionAppToState(const std::shared_ptr<app::AppInstance>
const app::AppManifest& app_manifest = app->getManifest();
const app::State old_state = app->getState();
LOGGER.info( "App \"{}\" state: {} -> {}",
app_manifest.appId,
LOG_I(TAG, "App \"%s\" state: %s -> %s",
app_manifest.appId.c_str(),
appStateToString(old_state),
appStateToString(state)
);
@@ -284,14 +285,14 @@ void LoaderService::stopTop() {
}
void LoaderService::stopTop(const std::string& id) {
LOGGER.info("dispatching stopTop({})", id);
LOG_I(TAG, "dispatching stopTop(%s)", id.c_str());
dispatcherThread->dispatch([this, id] {
onStopTopAppMessage(id);
});
}
void LoaderService::stopAll(const std::string& id) {
LOGGER.info("dispatching stopAll({})", id);
LOG_I(TAG, "dispatching stopAll(%s)", id.c_str());
dispatcherThread->dispatch([this, id] {
onStopAllAppMessage(id);
});