Implement an abstraction for the config (#358)

Fixes #321
This commit is contained in:
Alex Kremer
2022-11-01 17:59:23 +01:00
committed by GitHub
parent 8bd8ab9b8a
commit ea2837749a
22 changed files with 1159 additions and 326 deletions

View File

@@ -1,6 +1,5 @@
#include <util/Taggable.h>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/json.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
@@ -49,25 +48,6 @@ TagDecoratorFactory::make() const
}
}
TagDecoratorFactory::Type
TagDecoratorFactory::parseType(boost::json::object const& config)
{
if (!config.contains("log_tag_style"))
return TagDecoratorFactory::Type::NONE;
auto style = config.at("log_tag_style").as_string();
if (boost::iequals(style, "int") || boost::iequals(style, "uint"))
return TagDecoratorFactory::Type::UINT;
else if (boost::iequals(style, "null") || boost::iequals(style, "none"))
return TagDecoratorFactory::Type::NONE;
else if (boost::iequals(style, "uuid"))
return TagDecoratorFactory::Type::UUID;
else
throw std::runtime_error(
"Could not parse `log_tag_style`: expected `uint`, `uuid` or "
"`null`");
}
TagDecoratorFactory
TagDecoratorFactory::with(parent_t parent) const noexcept
{