feat(Log): harden LogState facade, bounded Logger delivery/tickets/quarantine, file sync/reopen, redaction, and separate LogConfig (M-LOG-01..05)
This commit is contained in:
1 parent
18a623aa62
commit
a74a402938
23 files changed
+2656
-1197
No files matched your search
@@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidLogOnlyConsumer LANGUAGES CXX)
|
||||
|
||||
find_package(Void CONFIG REQUIRED COMPONENTS Log)
|
||||
|
||||
add_executable(void_log_only_consumer main.cpp)
|
||||
target_link_libraries(void_log_only_consumer PRIVATE Void::Log)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME VoidLogOnlyConsumer COMMAND void_log_only_consumer)
|
||||
@@ -0,0 +1,26 @@
|
||||
#include <Void/Log/Log.hpp>
|
||||
#include <Void/Log/LoggingAdapter.hpp>
|
||||
#include <Void/Log/Sinks.hpp>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::atomic<int> seen{0};
|
||||
auto sink = std::make_shared<Void::Logging::CallbackLogger>(
|
||||
[&](const Void::Logging::Entry&) {
|
||||
seen.fetch_add(1, std::memory_order_relaxed);
|
||||
},
|
||||
Void::Logging::LoggerOptions{
|
||||
.mode = Void::Logging::Mode::Immediate,
|
||||
.policy = Void::Logging::OverflowPolicy::DropNewest});
|
||||
|
||||
const auto reg = Void::Log::register_sink(Void::Log::make_sink(sink), sink);
|
||||
Void::Log::info("LogOnly", "hello consumer");
|
||||
const auto dr = Void::Log::detach_and_drain(reg);
|
||||
const auto rep = sink->close({});
|
||||
return (dr == Void::Log::DrainResult::drained && rep.has_value() &&
|
||||
seen.load() == 1)
|
||||
? 0
|
||||
: 1;
|
||||
}
|
||||
Reference in new issue
Block a user