20 {
21 std::cout << "Testing backend integration..." << std::endl;
22
23
24 {
25 std::cout << "\n=== Test 1: Standalone Backend ===" << std::endl;
26 auto standalone_backend = std::make_unique<backends::standalone_backend>();
27 std::cout << "Backend name: " << standalone_backend->get_backend_name() << std::endl;
28
32 .
add_writer(
"console", std::make_unique<console_writer>())
34
35 if (logger_result) {
36 auto logger_inst = std::move(logger_result.value());
37 logger_inst->log(log_level::info, std::string("Test message from standalone backend"));
38 std::cout << "[PASS] Standalone backend test passed" << std::endl;
39 } else {
40 std::cerr << "[FAIL] Failed to build logger: " << logger_result.error_message() << std::endl;
41 return 1;
42 }
43 }
44
45
46
47
48
49 {
50 std::cout << "\n=== Test 2: Auto-Detection ===" << std::endl;
53 .
add_writer(
"console", std::make_unique<console_writer>())
55
56 if (logger_result) {
57 auto logger_inst = std::move(logger_result.value());
58 logger_inst->log(log_level::info, std::string("Test message with auto-detected backend"));
59 std::cout << "[PASS] Auto-detection test passed (standalone backend)" << std::endl;
60 } else {
61 std::cerr << "[FAIL] Failed to build logger: " << logger_result.error_message() << std::endl;
62 return 1;
63 }
64 }
65
66 std::cout << "\n=== All backend tests passed! ===" << std::endl;
67 return 0;
68}
Builder pattern for logger construction with validation.
logger_builder & with_standalone_backend()
Use standalone backend explicitly.
logger_builder & with_async(bool async=true)
result< std::unique_ptr< logger > > build()
logger_builder & add_writer(const std::string &name, log_writer_ptr writer)
Add a writer to the logger.