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>
72 lines
1.8 KiB
C++
72 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <Void/Detail/Enum.hpp>
|
|
|
|
#include <format>
|
|
#include <string_view>
|
|
#include <utility>
|
|
|
|
namespace Void::Logging
|
|
{
|
|
enum class Level { Disabled, Trace, Debug, Info, Warning, Error, Fatal };
|
|
|
|
[[nodiscard]] constexpr bool operator<(Level a, Level b) noexcept
|
|
{
|
|
return std::to_underlying(a) < std::to_underlying(b);
|
|
}
|
|
|
|
[[nodiscard]] constexpr bool operator<=(Level a, Level b) noexcept
|
|
{
|
|
return std::to_underlying(a) <= std::to_underlying(b);
|
|
}
|
|
|
|
[[nodiscard]] constexpr bool operator>(Level a, Level b) noexcept
|
|
{
|
|
return std::to_underlying(a) > std::to_underlying(b);
|
|
}
|
|
|
|
[[nodiscard]] constexpr bool operator>=(Level a, Level b) noexcept
|
|
{
|
|
return std::to_underlying(a) >= std::to_underlying(b);
|
|
}
|
|
|
|
/// Convert a Level to its identifier string via reflection when available,
|
|
/// falling back to a hand-written table for non-reflecting compilers.
|
|
[[nodiscard]] constexpr std::string_view to_string(Level level) noexcept
|
|
{
|
|
#ifdef VOID_HAS_ENUM_REFLECTION
|
|
return Void::Detail::enum_name(level);
|
|
#else
|
|
switch (level) {
|
|
case Level::Disabled:
|
|
return "Disabled";
|
|
case Level::Trace:
|
|
return "Trace";
|
|
case Level::Debug:
|
|
return "Debug";
|
|
case Level::Info:
|
|
return "Info";
|
|
case Level::Warning:
|
|
return "Warning";
|
|
case Level::Error:
|
|
return "Error";
|
|
case Level::Fatal:
|
|
return "Fatal";
|
|
default:
|
|
return "?";
|
|
}
|
|
#endif
|
|
}
|
|
} // namespace Void::Logging
|
|
|
|
// ADL-visible free overload so std::format("{}", level) works.
|
|
template <>
|
|
struct std::formatter<Void::Logging::Level> : std::formatter<std::string_view> {
|
|
template <class FormatContext>
|
|
auto format(Void::Logging::Level level, FormatContext& ctx) const
|
|
{
|
|
return std::formatter<std::string_view>::format(
|
|
Void::Logging::to_string(level), ctx);
|
|
}
|
|
};
|