Files
Ken Van Hoeylandt a935410f82 Kernel and buildscript improvements (#477)
* **New Features**
  * Centralized module management with global symbol resolution
  * Level-aware logging with colored prefixes and millisecond timestamps

* **Breaking Changes**
  * ModuleParent hierarchy and getModuleParent() removed
  * Logging API and adapter model replaced; LogLevel-driven log_generic signature changed

* **Improvements**
  * Unified, simplified module registration across build targets
  * Tests updated to reflect new module lifecycle and global symbol resolution
2026-02-03 08:35:29 +01:00

71 lines
1.8 KiB
C++

#pragma once
#include <tactility/log.h>
#include <format>
namespace tt {
class Logger {
const char* tag;
LogLevel level = LOG_LEVEL_INFO;
public:
explicit Logger(const char* tag) : tag(tag) {}
template <typename... Args>
void verbose(std::format_string<Args...> format, Args&&... args) const {
std::string message = std::format(format, std::forward<Args>(args)...);
LOG_V(tag, "%s", message.c_str());
}
template <typename... Args>
void debug(std::format_string<Args...> format, Args&&... args) const {
std::string message = std::format(format, std::forward<Args>(args)...);
LOG_D(tag, "%s", message.c_str());
}
template <typename... Args>
void info(std::format_string<Args...> format, Args&&... args) const {
std::string message = std::format(format, std::forward<Args>(args)...);
LOG_I(tag, "%s", message.c_str());
}
template <typename... Args>
void warn(std::format_string<Args...> format, Args&&... args) const {
std::string message = std::format(format, std::forward<Args>(args)...);
LOG_W(tag, "%s", message.c_str());
}
template <typename... Args>
void error(std::format_string<Args...> format, Args&&... args) const {
std::string message = std::format(format, std::forward<Args>(args)...);
LOG_E(tag, "%s", message.c_str());
}
bool isLoggingVerbose() const {
return LOG_LEVEL_VERBOSE <= level;
}
bool isLoggingDebug() const {
return LOG_LEVEL_DEBUG <= level;
}
bool isLoggingInfo() const {
return LOG_LEVEL_INFO <= level;
}
bool isLoggingWarning() const {
return LOG_LEVEL_WARNING <= level;
}
bool isLoggingError() const {
return LOG_LEVEL_ERROR <= level;
}
};
}