Restructure into umbrella modules (~55 -> 16 targets)
Headers move, CMake targets merge, C++ namespaces stay unchanged: - Core: Scope, Lazy, Counted, Flags, Hash, Bits, Uuid, TypeList, TypeMap, Variant - Functional: Pipeline, Either, Result, Retry - Containers: Ring, Pool, PriorityQueue, LRU, Trie, Graph, DisjointSet, Bitset, Interval - Math: +Matrix, Numeric, Random, Histogram - Text: Str, Format, Tokenizer, Diff, Encoding, Semver - Data: Json, Csv, Ini - Async: Coro, Concurrency, EventBus, Observable - Time: +Bench - Log: Log facade + Logging framework (facade now header-only, breaking the Stacktrace<->Log link cycle the merge would have created) - System: FileSystem + Process - Configuration: +Argparse - Unchanged: Stacktrace, Plugin, StateMachine, Testing, TestingMock, Detail Module system fixes: - OPTIONAL_DEPS resolution deferred to void_finalize_modules() so it no longer depends on the alphabetical discovery order of src/ subdirs (Testing -> Text would have been silently dropped). - Every header-only module now has a tracked module.cmake; previously the empty src/<Name> marker dirs were untracked, so a fresh clone would have silently skipped those modules. - VOID_HAS_LOGGING/CONCURRENCY/STR consumers renamed to LOG/ASYNC/TEXT. Tests move to tests/standalone/<Umbrella>/<Feature>.cpp (Result suite files prefixed: ResultBasic etc.). Test count verified identical (831) before and after. README/CLAUDE.md module tables updated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
da2e93c405
commit
28b94883fd
156 files changed
+278
-220
No files matched your search
@@ -0,0 +1,96 @@
|
||||
#include <Void/Detail/Enum.hpp>
|
||||
#include <Void/Log/ConsoleLogger.hpp>
|
||||
|
||||
#ifdef VOID_HAS_STACKTRACE
|
||||
#include <Void/Stacktrace/Color.hpp>
|
||||
#endif
|
||||
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace Void::Logging
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
#ifdef VOID_HAS_STACKTRACE
|
||||
std::string_view color_for(Level level)
|
||||
{
|
||||
using namespace Void::Stacktrace::Color;
|
||||
#ifdef VOID_HAS_ENUM_REFLECTION
|
||||
static constexpr auto enumerators =
|
||||
std::define_static_array(std::meta::enumerators_of(^^Level));
|
||||
template for (constexpr auto e : enumerators) {
|
||||
if (level == [:e:]) {
|
||||
if constexpr (std::meta::identifier_of(e) == "Trace")
|
||||
return dim;
|
||||
if constexpr (std::meta::identifier_of(e) == "Debug")
|
||||
return cyan;
|
||||
if constexpr (std::meta::identifier_of(e) == "Info")
|
||||
return bold_cyan;
|
||||
if constexpr (std::meta::identifier_of(e) == "Warning")
|
||||
return bold_yellow;
|
||||
if constexpr (std::meta::identifier_of(e) == "Error")
|
||||
return bold_red;
|
||||
if constexpr (std::meta::identifier_of(e) == "Fatal")
|
||||
return bold_magenta;
|
||||
return reset;
|
||||
}
|
||||
}
|
||||
return reset;
|
||||
#else
|
||||
switch (level) {
|
||||
case Level::Trace:
|
||||
return dim;
|
||||
case Level::Debug:
|
||||
return cyan;
|
||||
case Level::Info:
|
||||
return bold_cyan;
|
||||
case Level::Warning:
|
||||
return bold_yellow;
|
||||
case Level::Error:
|
||||
return bold_red;
|
||||
case Level::Fatal:
|
||||
return bold_magenta;
|
||||
default:
|
||||
return reset;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string format_entry(const Entry& entry)
|
||||
{
|
||||
auto level_str = std::string{to_string(entry.level)};
|
||||
#ifdef VOID_HAS_STACKTRACE
|
||||
using namespace Void::Stacktrace::Color;
|
||||
return std::format("[{}] {}\n",
|
||||
apply(color_for(entry.level), level_str),
|
||||
entry.message);
|
||||
#else
|
||||
return std::format("[{}] {}\n", level_str, entry.message);
|
||||
#endif
|
||||
}
|
||||
} // namespace
|
||||
|
||||
ConsoleLogger::ConsoleLogger(std::ostream& out,
|
||||
Mode mode,
|
||||
std::size_t capacity)
|
||||
: Logger(mode, capacity), m_out(out)
|
||||
{
|
||||
}
|
||||
|
||||
ConsoleLogger::ConsoleLogger() : ConsoleLogger(std::cerr) {}
|
||||
|
||||
ConsoleLogger::~ConsoleLogger() noexcept { flush(); }
|
||||
|
||||
void ConsoleLogger::write(const Entry& entry)
|
||||
{
|
||||
m_out << format_entry(entry);
|
||||
m_out.flush();
|
||||
}
|
||||
|
||||
} // namespace Void::Logging
|
||||
Reference in new issue
Block a user