# CS-04 logging framework, built in steps. Each step is the whole
# program at that point in the study, and is built and tested on its own.
#   step-1  levels, named loggers, sinks, two formats, an async sink with
#           a bounded queue, and a log system that is not a singleton
#   step-2  change: structured fields, JSON lines, a rotating file sink
find_package(Threads REQUIRED)

foreach(step IN ITEMS 1 2)
  add_library(cs_logging_step${step} STATIC
    step-${step}/format.cpp step-${step}/sinks.cpp step-${step}/async_sink.cpp
    step-${step}/log_system.cpp)
  target_include_directories(cs_logging_step${step} PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/step-${step})
  target_link_libraries(cs_logging_step${step} PUBLIC Threads::Threads)
  lld_add_test(cs_logging_step${step}_tests
    SOURCES step-${step}/tests/test_step${step}.cpp LABELS unit concurrency)
  target_link_libraries(cs_logging_step${step}_tests PRIVATE cs_logging_step${step})
  lld_add_example(cs_logging_step${step}_demo SOURCES step-${step}/main.cpp
    EXPECTED_OUTPUT step-${step}/expected_output.txt)
  target_link_libraries(cs_logging_step${step}_demo PRIVATE cs_logging_step${step})
endforeach()
