New logging and more (#446)

- `TT_LOG_*` macros are replaced by `Logger` via `#include<Tactility/Logger.h>`
- Changed default timezone to Europe/Amsterdam
- Fix for logic bug in unPhone hardware
- Fix for init/deinit in DRV2605 driver
- Other fixes
- Removed optimization that broke unPhone (disabled the moving of heap-related functions to flash)
This commit is contained in:
Ken Van Hoeylandt
2026-01-06 22:35:39 +01:00
committed by GitHub
parent 719f7bcece
commit f620255c41
188 changed files with 1973 additions and 1755 deletions
+10 -9
View File
@@ -14,7 +14,7 @@
#pragma once
#include "CoreDefines.h"
#include "Log.h"
#include "Logger.h"
#include <cassert>
@@ -28,17 +28,18 @@ namespace tt {
TT_NORETURN void _crash();
}
// TODO: Move crash logic to kernel namespace and consider refactoring to C++
/** Crash system with message. */
#define tt_crash(...) TT_ARG_CAT(_tt_crash,TT_ARGCOUNT(__VA_ARGS__))(__VA_ARGS__)
#define _tt_crash0() do { \
TT_LOG_E("crash", "at %s:%d", __FILE__, __LINE__); \
tt::Logger("Kernel").error("Crash at {}:{}", __FILE__, __LINE__); \
tt::_crash(); \
} while (0)
#define _tt_crash1(message) do { \
TT_LOG_E("crash", "%s\n\tat %s:%d", message, __FILE__, __LINE__); \
tt::_crash(); \
#define _tt_crash1(message) do { \
tt::Logger("Kernel").error("Crash: {}\n\tat {}:{}", message, __FILE__, __LINE__); \
tt::_crash(); \
} while (0)
/** Halt the system
@@ -50,11 +51,11 @@ namespace tt {
#define tt_check_internal(__e, __m) \
do { \
if (!(__e)) { \
TT_LOG_E("check", "%s", #__e); \
tt::Logger("Kernel").error("Check failed: {}", #__e); \
if (__m) { \
tt_crash_internal(#__m); \
tt_crash(__m); \
} else { \
tt_crash_internal(""); \
tt_crash(""); \
} \
} \
} while (0)
@@ -65,4 +66,4 @@ namespace tt {
* @param[in] optional message (const char*)
*/
#define tt_check(x, ...) if (!(x)) { TT_LOG_E("check", "Failed: %s", #x); tt::_crash(); }
#define tt_check(x, ...) if (!(x)) { tt::Logger("Kernel").error("Check failed: {}", #x); tt::_crash(); }
-10
View File
@@ -1,10 +0,0 @@
#pragma once
#ifdef ESP_PLATFORM
#include "LogEsp.h"
#else
#include "LogSimulator.h"
#endif
#include "LogMessages.h"
#include "LogCommon.h"
-19
View File
@@ -1,19 +0,0 @@
#pragma once
#ifdef ESP_PLATFORM
#include <esp_log.h>
#include "Tactility/LogCommon.h"
#define TT_LOG_E(tag, format, ...) \
ESP_LOGE(tag, format, ##__VA_ARGS__)
#define TT_LOG_W(tag, format, ...) \
ESP_LOGW(tag, format, ##__VA_ARGS__)
#define TT_LOG_I(tag, format, ...) \
ESP_LOGI(tag, format, ##__VA_ARGS__)
#define TT_LOG_D(tag, format, ...) \
ESP_LOGD(tag, format, ##__VA_ARGS__)
#define TT_LOG_V(tag, format, ...) \
ESP_LOGV(tag, format, ##__VA_ARGS__)
#endif // ESP_PLATFORM
+2 -11
View File
@@ -9,20 +9,11 @@
// Alloc
#define LOG_MESSAGE_ALLOC_FAILED "Out of memory"
#define LOG_MESSAGE_ALLOC_FAILED_FMT "Out of memory (failed to allocated %zu bytes)"
#define LOG_MESSAGE_ALLOC_FAILED_FMT "Out of memory (failed to allocated {} bytes)"
// Mutex
#define LOG_MESSAGE_MUTEX_LOCK_FAILED "Mutex acquisition timeout"
#define LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT "Mutex acquisition timeout (%s)"
// SPI
#define LOG_MESSAGE_SPI_INIT_START_FMT "SPI %d init"
#define LOG_MESSAGE_SPI_INIT_FAILED_FMT "SPI %d init failed"
// I2C
#define LOG_MESSAGE_I2C_INIT_START "I2C init"
#define LOG_MESSAGE_I2C_INIT_CONFIG_FAILED "I2C config failed"
#define LOG_MESSAGE_I2C_INIT_DRIVER_INSTALL_FAILED "I2C driver install failed"
#define LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT "Mutex acquisition timeout ({})"
// Power on
#define LOG_MESSAGE_POWER_ON_START "Power on"
@@ -1,27 +0,0 @@
#pragma once
#ifndef ESP_PLATFORM
#include "LogCommon.h"
#include <cstdarg>
#include <cstdio>
namespace tt {
void log(LogLevel level, const char* tag, const char* format, ...);
} // namespace
#define TT_LOG_E(tag, format, ...) \
tt::log(tt::LogLevel::Error, tag, format, ##__VA_ARGS__)
#define TT_LOG_W(tag, format, ...) \
tt::log(tt::LogLevel::Warning, tag, format, ##__VA_ARGS__)
#define TT_LOG_I(tag, format, ...) \
tt::log(tt::LogLevel::Info, tag, format, ##__VA_ARGS__)
#define TT_LOG_D(tag, format, ...) \
tt::log(tt::LogLevel::Debug, tag, format, ##__VA_ARGS__)
#define TT_LOG_V(tag, format, ...) \
tt::log(tt::LogLevel::Verbose, tag, format, ##__VA_ARGS__)
#endif // ESP_PLATFORM
+72
View File
@@ -0,0 +1,72 @@
#pragma once
#include "LoggerAdapter.h"
#include "LoggerSettings.h"
#ifdef ESP_PLATFORM
#include "LoggerAdapterEsp.h"
#else
#include "LoggerAdapterGeneric.h"
#endif
#include <format>
namespace tt {
#ifdef ESP_PLATFORM
static LoggerAdapter defaultLoggerAdapter = espLoggerAdapter;
#else
static LoggerAdapter defaultLoggerAdapter = genericLoggerAdapter;
#endif
class Logger {
const char* tag;
public:
explicit Logger(const char* tag) : tag(tag) {}
template <typename... Args>
void log(LogLevel level, std::format_string<Args...> format, Args&&... args) const {
std::string message = std::format(format, std::forward<Args>(args)...);
defaultLoggerAdapter(level, tag, message.c_str());
}
template <typename... Args>
void verbose(std::format_string<Args...> format, Args&&... args) const {
log(LogLevel::Verbose, format, std::forward<Args>(args)...);
}
template <typename... Args>
void debug(std::format_string<Args...> format, Args&&... args) const {
log(LogLevel::Debug, format, std::forward<Args>(args)...);
}
template <typename... Args>
void info(std::format_string<Args...> format, Args&&... args) const {
log(LogLevel::Info, format, std::forward<Args>(args)...);
}
template <typename... Args>
void warn(std::format_string<Args...> format, Args&&... args) const {
log(LogLevel::Warning, format, std::forward<Args>(args)...);
}
template <typename... Args>
void error(std::format_string<Args...> format, Args&&... args) const {
log(LogLevel::Error, format, std::forward<Args>(args)...);
}
bool isLoggingVerbose() const { return LogLevel::Verbose <= LOG_LEVEL; }
bool isLoggingDebug() const { return LogLevel::Debug <= LOG_LEVEL; }
bool isLoggingInfo() const { return LogLevel::Info <= LOG_LEVEL; }
bool isLoggingWarning() const { return LogLevel::Warning <= LOG_LEVEL; }
bool isLoggingError() const { return LogLevel::Error <= LOG_LEVEL; }
};
}
@@ -0,0 +1,10 @@
#pragma once
#include "LoggerCommon.h"
#include <functional>
namespace tt {
typedef std::function<void(LogLevel level, const char* tag, const char* message)> LoggerAdapter;
}
@@ -0,0 +1,35 @@
#pragma once
#include "LoggerAdapter.h"
#include "LoggerAdapterShared.h"
#include <esp_log.h>
#include <sstream>
namespace tt {
inline esp_log_level_t toEspLogLevel(LogLevel level) {
switch (level) {
case LogLevel::Error:
return ESP_LOG_ERROR;
case LogLevel::Warning:
return ESP_LOG_WARN;
case LogLevel::Info:
return ESP_LOG_INFO;
case LogLevel::Debug:
return ESP_LOG_DEBUG;
case LogLevel::Verbose:
default:
return ESP_LOG_VERBOSE;
}
}
static const LoggerAdapter espLoggerAdapter = [](LogLevel level, const char* tag, const char* message) {
constexpr auto COLOR_RESET = "\033[0m";
constexpr auto COLOR_GREY = "\033[37m";
std::stringstream buffer;
buffer << COLOR_GREY << esp_log_timestamp() << ' ' << toTagColour(level) << toPrefix(level) << COLOR_GREY << " [" << COLOR_RESET << tag << COLOR_GREY << "] " << toMessageColour(level) << message << COLOR_RESET << std::endl;
esp_log_write(toEspLogLevel(level), tag, "%s", buffer.str().c_str());
};
}
@@ -0,0 +1,35 @@
#pragma once
#include "LoggerAdapter.h"
#include "LoggerAdapterShared.h"
#include <cstdint>
#include <mutex>
#include <sstream>
#include <sys/time.h>
namespace tt {
static uint64_t getLogTimestamp() {
static uint64_t base = 0U;
static std::once_flag init_flag;
std::call_once(init_flag, []() {
timeval time {};
gettimeofday(&time, nullptr);
base = ((uint64_t)time.tv_sec * 1000U) + (time.tv_usec / 1000U);
});
timeval time {};
gettimeofday(&time, nullptr);
uint64_t now = ((uint64_t)time.tv_sec * 1000U) + (time.tv_usec / 1000U);
return now - base;
}
static const LoggerAdapter genericLoggerAdapter = [](LogLevel level, const char* tag, const char* message) {
constexpr auto COLOR_RESET = "\033[0m";
constexpr auto COLOR_GREY = "\033[37m";
std::stringstream buffer;
buffer << COLOR_GREY << getLogTimestamp() << ' ' << toTagColour(level) << toPrefix(level) << COLOR_GREY << " [" << COLOR_RESET << tag << COLOR_GREY << "] " << toMessageColour(level) << message << COLOR_RESET << std::endl;
printf(buffer.str().c_str());
};
}
@@ -0,0 +1,58 @@
#pragma once
#include "LoggerCommon.h"
namespace tt {
inline const char* toTagColour(LogLevel level) {
using enum LogLevel;
switch (level) {
case Error:
return "\033[1;31m";
case Warning:
return "\033[1;33m";
case Info:
return "\033[32m";
case Debug:
return "\033[36m";
case Verbose:
return "\033[37m";
default:
return "";
}
}
inline const char* toMessageColour(LogLevel level) {
using enum LogLevel;
switch (level) {
case Error:
return "\033[1;31m";
case Warning:
return "\033[1;33m";
case Info:
case Debug:
case Verbose:
return "\033[0m";
default:
return "";
}
}
inline char toPrefix(LogLevel level) {
using enum LogLevel;
switch (level) {
case Error:
return 'E';
case Warning:
return 'W';
case Info:
return 'I';
case Debug:
return 'D';
case Verbose:
default:
return 'V';
}
}
}
@@ -0,0 +1,9 @@
#pragma once
#include "LoggerCommon.h"
namespace tt {
constexpr auto LOG_LEVEL = LogLevel::Info;
}
@@ -2,9 +2,6 @@
#include <cstdio>
#include "Tactility/Thread.h"
#include "Check.h"
#include "CoreDefines.h"
#include "Log.h"
#include <Tactility/kernel/Kernel.h>
#include "Logger.h"
+12 -12
View File
@@ -1,28 +1,28 @@
#include <Tactility/Check.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <Tactility/freertoscompat/Task.h>
constexpr auto TAG = "kernel";
static const auto LOGGER = tt::Logger("kernel");
static void logMemoryInfo() {
#ifdef ESP_PLATFORM
TT_LOG_E(TAG, "default caps:");
TT_LOG_E(TAG, " total: %u", heap_caps_get_total_size(MALLOC_CAP_DEFAULT));
TT_LOG_E(TAG, " free: %u", heap_caps_get_free_size(MALLOC_CAP_DEFAULT));
TT_LOG_E(TAG, " min free: %u", heap_caps_get_minimum_free_size(MALLOC_CAP_DEFAULT));
TT_LOG_E(TAG, "internal caps:");
TT_LOG_E(TAG, " total: %u", heap_caps_get_total_size(MALLOC_CAP_INTERNAL));
TT_LOG_E(TAG, " free: %u", heap_caps_get_free_size(MALLOC_CAP_INTERNAL));
TT_LOG_E(TAG, " min free: %u", heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL));
LOGGER.error("default caps:");
LOGGER.error(" total: {}", heap_caps_get_total_size(MALLOC_CAP_DEFAULT));
LOGGER.error(" free: {}", heap_caps_get_free_size(MALLOC_CAP_DEFAULT));
LOGGER.error(" min free: {}", heap_caps_get_minimum_free_size(MALLOC_CAP_DEFAULT));
LOGGER.error("internal caps:");
LOGGER.error(" total: {}", heap_caps_get_total_size(MALLOC_CAP_INTERNAL));
LOGGER.error(" free: {}", heap_caps_get_free_size(MALLOC_CAP_INTERNAL));
LOGGER.error(" min free: {}", heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL));
#endif
}
static void logTaskInfo() {
const char* name = pcTaskGetName(nullptr);
const char* safe_name = name ? name : "main";
TT_LOG_E(TAG, "Task: %s", safe_name);
TT_LOG_E(TAG, "Stack watermark: %u", uxTaskGetStackHighWaterMark(NULL) * 4);
LOGGER.error("Task: {}", safe_name);
LOGGER.error("Stack watermark: {}", uxTaskGetStackHighWaterMark(NULL) * 4);
}
namespace tt {
-86
View File
@@ -1,86 +0,0 @@
#ifndef ESP_PLATFORM
#include "Tactility/Log.h"
#include <cstdint>
#include <iomanip>
#include <sstream>
#include <sys/time.h>
namespace tt {
static char toPrefix(LogLevel level) {
using enum LogLevel;
switch (level) {
case Error:
return 'E';
case Warning:
return 'W';
case Info:
return 'I';
case Debug:
return 'D';
case Verbose:
return 'V';
default:
return ' ';
}
}
static const char* toTagColour(LogLevel level) {
using enum LogLevel;
switch (level) {
case Error:
return "\033[1;31m";
case Warning:
return "\033[1;33m";
case Info:
return "\033[32m";
case Debug:
return "\033[36m";
case Verbose:
return "\033[37m";
default:
return "";
}
}
static const char* toMessageColour(LogLevel level) {
using enum LogLevel;
switch (level) {
case Error:
return "\033[1;31m";
case Warning:
return "\033[1;33m";
case Info:
case Debug:
case Verbose:
return "\033[0m";
default:
return "";
}
}
static uint64_t getLogTimestamp() {
static uint64_t base = 0U;
struct timeval time {};
gettimeofday(&time, nullptr);
uint64_t now = ((uint64_t)time.tv_sec * 1000U) + (time.tv_usec / 1000U);
if (base == 0U) {
base = now;
}
return now - base;
}
void log(LogLevel level, const char* tag, const char* format, ...) {
std::stringstream buffer;
buffer << getLogTimestamp() << " [" << toTagColour(level) << toPrefix(level) << "\033[0m" << "] [" << tag << "] " << toMessageColour(level) << format << "\033[0m\n";
va_list args;
va_start(args, format);
vprintf(buffer.str().c_str(), args);
va_end(args);
}
} // namespace tt
#endif
+12 -11
View File
@@ -1,7 +1,7 @@
#include "Tactility/crypt/Crypt.h"
#include <Tactility/crypt/Crypt.h>
#include "Tactility/Check.h"
#include "Tactility/Log.h"
#include <Tactility/Check.h>
#include <Tactility/Logger.h>
#include <mbedtls/aes.h>
#include <cstring>
@@ -15,7 +15,8 @@
namespace tt::crypt {
#define TAG "secure"
static const auto LOGGER = Logger("Crypt");
#define TT_NVS_NAMESPACE "tt_secure"
#ifdef ESP_PLATFORM
@@ -27,7 +28,7 @@ static void get_hardware_key(uint8_t key[32]) {
uint8_t mac[8];
// MAC can be 6 or 8 bytes
size_t mac_length = esp_mac_addr_len_get(ESP_MAC_EFUSE_FACTORY);
TT_LOG_I(TAG, "Using MAC with length %u", mac_length);
LOGGER.info("Using MAC with length {}", mac_length);
tt_check(mac_length <= 8);
ESP_ERROR_CHECK(esp_read_mac(mac, ESP_MAC_EFUSE_FACTORY));
@@ -66,13 +67,13 @@ static void get_nvs_key(uint8_t key[32]) {
esp_err_t result = nvs_open(TT_NVS_NAMESPACE, NVS_READWRITE, &handle);
if (result != ESP_OK) {
TT_LOG_E(TAG, "Failed to get key from NVS (%s)", esp_err_to_name(result));
LOGGER.error("Failed to get key from NVS ({})", esp_err_to_name(result));
tt_crash("NVS error");
}
size_t length = 32;
if (nvs_get_blob(handle, "key", key, &length) == ESP_OK) {
TT_LOG_I(TAG, "Fetched key from NVS (%d bytes)", length);
LOGGER.info("Fetched key from NVS ({} bytes)", length);
tt_check(length == 32);
} else {
// TODO: Improved randomness
@@ -83,7 +84,7 @@ static void get_nvs_key(uint8_t key[32]) {
key[i] = (uint8_t)(rand());
}
ESP_ERROR_CHECK(nvs_set_blob(handle, "key", key, 32));
TT_LOG_I(TAG, "Stored new key in NVS");
LOGGER.info("Stored new key in NVS");
}
nvs_close(handle);
@@ -109,8 +110,8 @@ static void xorKey(const uint8_t* inLeft, const uint8_t* inRight, uint8_t* out,
*/
static void getKey(uint8_t key[32]) {
#if !defined(CONFIG_SECURE_BOOT) || !defined(CONFIG_SECURE_FLASH_ENC_ENABLED)
TT_LOG_W(TAG, "Using tt_secure_* code with secure boot and/or flash encryption disabled.");
TT_LOG_W(TAG, "An attacker with physical access to your ESP32 can decrypt your secure data.");
LOGGER.warn("Using tt_secure_* code with secure boot and/or flash encryption disabled.");
LOGGER.warn("An attacker with physical access to your ESP32 can decrypt your secure data.");
#endif
#ifdef ESP_PLATFORM
@@ -121,7 +122,7 @@ static void getKey(uint8_t key[32]) {
get_nvs_key(nvs_key);
xorKey(hardware_key, nvs_key, key, 32);
#else
TT_LOG_W(TAG, "Using unsafe key for debugging purposes.");
LOGGER.warn("Using unsafe key for debugging purposes.");
memset(key, 0, 32);
#endif
}
+25 -23
View File
@@ -1,8 +1,10 @@
#include "Tactility/file/File.h"
#include <Tactility/file/File.h>
#include <cstring>
#include <fstream>
#include <unistd.h>
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h>
namespace tt::hal::sdcard {
@@ -11,7 +13,7 @@ class SdCardDevice;
namespace tt::file {
constexpr auto* TAG = "file";
static const auto LOGGER = Logger("file");
class NoLock final : public Lock {
bool lock(TickType_t timeout) const override { return true; }
@@ -23,7 +25,7 @@ static std::function<std::shared_ptr<Lock>(const std::string&)> findLockFunction
std::shared_ptr<Lock> getLock(const std::string& path) {
if (findLockFunction == nullptr) {
TT_LOG_W(TAG, "File lock function not set!");
LOGGER.warn("File lock function not set!");
return noLock;
}
@@ -69,10 +71,10 @@ bool listDirectory(
auto lock = getLock(path)->asScopedLock();
lock.lock();
TT_LOG_I(TAG, "listDir start %s", path.c_str());
LOGGER.info("listDir start {}", path);
DIR* dir = opendir(path.c_str());
if (dir == nullptr) {
TT_LOG_E(TAG, "Failed to open dir %s", path.c_str());
LOGGER.error("Failed to open dir {}", path);
return false;
}
@@ -83,7 +85,7 @@ bool listDirectory(
closedir(dir);
TT_LOG_I(TAG, "listDir stop %s", path.c_str());
LOGGER.info("listDir stop {}", path);
return true;
}
@@ -96,10 +98,10 @@ int scandir(
auto lock = getLock(path)->asScopedLock();
lock.lock();
TT_LOG_I(TAG, "scandir start");
LOGGER.info("scandir start");
DIR* dir = opendir(path.c_str());
if (dir == nullptr) {
TT_LOG_E(TAG, "Failed to open dir %s", path.c_str());
LOGGER.error("Failed to open dir {}", path);
return -1;
}
@@ -116,7 +118,7 @@ int scandir(
std::ranges::sort(outList, sortMethod);
}
TT_LOG_I(TAG, "scandir finish");
LOGGER.info("scandir finish");
return outList.size();
}
@@ -125,18 +127,18 @@ long getSize(FILE* file) {
long original_offset = ftell(file);
if (fseek(file, 0, SEEK_END) != 0) {
TT_LOG_E(TAG, "fseek failed");
LOGGER.error("fseek failed");
return -1;
}
long file_size = ftell(file);
if (file_size == -1) {
TT_LOG_E(TAG, "Could not get file length");
LOGGER.error("Could not get file length");
return -1;
}
if (fseek(file, original_offset, SEEK_SET) != 0) {
TT_LOG_E(TAG, "fseek Failed");
LOGGER.error("fseek Failed");
return -1;
}
@@ -152,26 +154,26 @@ static std::unique_ptr<uint8_t[]> readBinaryInternal(const std::string& filepath
FILE* file = fopen(filepath.c_str(), "rb");
if (file == nullptr) {
TT_LOG_E(TAG, "Failed to open %s", filepath.c_str());
LOGGER.error("Failed to open {}", filepath);
return nullptr;
}
long content_length = getSize(file);
if (content_length == -1) {
TT_LOG_E(TAG, "Failed to determine content length for %s", filepath.c_str());
LOGGER.error("Failed to determine content length for {}", filepath);
return nullptr;
}
auto data = std::make_unique<uint8_t[]>(content_length + sizePadding);
if (data == nullptr) {
TT_LOG_E(TAG, "Insufficient memory. Failed to allocate %ldl bytes.", content_length);
LOGGER.error("Insufficient memory. Failed to allocate {} bytes.", content_length);
return nullptr;
}
size_t buffer_offset = 0;
while (buffer_offset < content_length) {
size_t bytes_read = fread(&data.get()[buffer_offset], 1, content_length - buffer_offset, file);
TT_LOG_D(TAG, "Read %d bytes", bytes_read);
LOGGER.debug("Read {} bytes", bytes_read);
if (bytes_read > 0) {
buffer_offset += bytes_read;
} else { // Something went wrong?
@@ -268,7 +270,7 @@ bool findOrCreateDirectory(const std::string& path, mode_t mode) {
if (path.empty()) {
return true;
}
TT_LOG_D(TAG, "findOrCreate: %s %lu", path.c_str(), mode);
LOGGER.debug("findOrCreate: {} {}", path, mode);
const char separator_to_find[] = {SEPARATOR, 0x00};
auto first_index = path[0] == SEPARATOR ? 1 : 0;
@@ -280,10 +282,10 @@ bool findOrCreateDirectory(const std::string& path, mode_t mode) {
auto to_create = is_last_segment ? path : path.substr(0, separator_index);
should_break = is_last_segment;
if (!findOrCreateDirectoryInternal(to_create, mode)) {
TT_LOG_E(TAG, "Failed to create %s", to_create.c_str());
LOGGER.error("Failed to create {}", to_create);
return false;
} else {
TT_LOG_D(TAG, " - got: %s", to_create.c_str());
LOGGER.debug(" - got: {}", to_create);
}
// Find next file separator index
@@ -309,7 +311,7 @@ bool deleteRecursively(const std::string& path) {
if (isDirectory(path)) {
std::vector<dirent> entries;
if (scandir(path, entries) < 0) {
TT_LOG_E(TAG, "Failed to scan directory %s", path.c_str());
LOGGER.error("Failed to scan directory {}", path);
return false;
}
@@ -319,16 +321,16 @@ bool deleteRecursively(const std::string& path) {
return false;
}
}
TT_LOG_I(TAG, "Deleting %s", path.c_str());
LOGGER.info("Deleting {}", path);
return deleteDirectory(path);
} else if (isFile(path)) {
TT_LOG_I(TAG, "Deleting %s", path.c_str());
LOGGER.info("Deleting {}", path);
return deleteFile(path);
} else if (path == "/" || path == "." || path == "..") {
// No-op
return true;
} else {
TT_LOG_E(TAG, "Failed to delete \"%s\": unknown type", path.c_str());
LOGGER.error("Failed to delete \"{}\": unknown type", path);
return false;
}
}