|
|
@ -7,11 +7,15 @@ |
|
|
|
#include <unordered_map>
|
|
|
|
#include <functional>
|
|
|
|
#include <any>
|
|
|
|
#include "nlohmann/json.hpp"
|
|
|
|
|
|
|
|
#if defined(__linux__) || defined(__linux)
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <memory>
|
|
|
|
#include <thread>
|
|
|
|
#include <future>
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
@ -132,223 +136,6 @@ void register_log_impl(int log_id, std::string_view log_name, std::string_view f |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) { |
|
|
|
register_log_impl<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory); |
|
|
|
} |
|
|
|
|
|
|
|
BufferStrategyInternal::buffer_type BufferStrategyInternal::build_buffer(std::string_view, size_t sz) { |
|
|
|
return std::vector<char>(sz, 0); |
|
|
|
} |
|
|
@ -379,7 +166,15 @@ BufferStrategyExternal::buffer_type BufferStrategyExternal::build_buffer(std::st |
|
|
|
} |
|
|
|
|
|
|
|
void SinkStrategyDirect::write(int fd, std::string_view data) { |
|
|
|
|
|
|
|
do{ |
|
|
|
auto written = ::write(fd, data.data(), data.size()); |
|
|
|
if(written < 0) { |
|
|
|
throw std::runtime_error("POSIX write failed"); |
|
|
|
} else if(written == 0) { |
|
|
|
throw std::runtime_error("POSIX write made no progress"); |
|
|
|
} |
|
|
|
data.substr(written); |
|
|
|
} while(not data.empty()); |
|
|
|
} |
|
|
|
|
|
|
|
void SinkStrategyFastest::write(int fd, std::string_view data) { |
|
|
@ -395,7 +190,7 @@ void SinkStrategyExternal::write(int fd, std::string_view data) { |
|
|
|
} |
|
|
|
|
|
|
|
void OverflowStrategyWait::wait() { |
|
|
|
|
|
|
|
std::this_thread::yield(); |
|
|
|
} |
|
|
|
|
|
|
|
void OverflowStrategyContinue::wait() { |
|
|
@ -425,3 +220,39 @@ std::pair OutputStrategySimple::chunk(std::s |
|
|
|
int OutputStrategySimple::on_write_completed_event(std::string_view, int) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
static nlohmann::json type_check_log_config(nlohmann::json&& data) { |
|
|
|
if(not data.is_object()) return {}; |
|
|
|
|
|
|
|
if(not data.contains("on_overflow") and not data["on_overflow"].is_string()) return {}; |
|
|
|
if(not data.contains("buffer_type")) return {}; |
|
|
|
if(auto& type = data.at("buffer_type"); not (type.is_string() and type.get<std::string>() == "internal") and not data.contains("buffer_filename")) return {}; |
|
|
|
} |
|
|
|
|
|
|
|
static void process_one(const nlohmann::json& data) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void sl::process_log_config(const std::string_view &filename) { |
|
|
|
std::ifstream config{std::string(filename)}; |
|
|
|
nlohmann::json data; |
|
|
|
config >> data; |
|
|
|
if(data.is_array()) { |
|
|
|
for(auto& elem : data) { |
|
|
|
elem = type_check_log_config(std::move(elem)); |
|
|
|
if(elem.empty()) { |
|
|
|
// TODO: handle error
|
|
|
|
} |
|
|
|
process_one(elem); |
|
|
|
} |
|
|
|
} else if (data.is_object()) { |
|
|
|
data = type_check_log_config(std::move(data)); |
|
|
|
if(data.empty()) { |
|
|
|
// TODO: handle error
|
|
|
|
} |
|
|
|
process_one(data); |
|
|
|
} else { |
|
|
|
// TODO: handle error
|
|
|
|
} |
|
|
|
} |
|
|
|
|