logger fixes

This commit is contained in:
Sascha Kühl 2026-02-04 15:13:27 +01:00
parent 520b2bab49
commit 1a1ecd1613
8 changed files with 48 additions and 32 deletions

View File

@ -2,8 +2,8 @@ CPMAddPackage("gh:catchorg/Catch2@3.7.1")
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
#set(POSTGRES_CONNECTION_STRING "postgres://test:test123!@127.0.0.1:15442/matador")
set(POSTGRES_CONNECTION_STRING "postgres://test:test123!@127.0.0.1:5432/matador")
set(POSTGRES_CONNECTION_STRING "postgres://test:test123!@127.0.0.1:15442/matador")
#set(POSTGRES_CONNECTION_STRING "postgres://test:test123!@127.0.0.1:5432/matador")
configure_file(Connection.hpp.in ${PROJECT_BINARY_DIR}/backends/postgres/test/connection.hpp @ONLY IMMEDIATE)

View File

@ -31,8 +31,8 @@ std::ostream& operator<<(std::ostream &os, log_level lvl);
/// @cond MATADOR_DEV
struct log_level_range {
log_level min_level = log_level::Info;
log_level max_level = log_level::Fatal;
log_level min_level = log_level::Fatal;
log_level max_level = log_level::Info;
};
/// @endcond

View File

@ -73,9 +73,8 @@ public:
template<class CollectionType>
void on_has_many(const char * /*id*/, CollectionType &cont, const char *join_column, const utils::foreign_attributes &attr, std::enable_if_t<object::is_object_ptr<typename CollectionType::value_type>::value> * = nullptr);
template<class CollectionType>
void on_has_many(const char * /*id*/, CollectionType &, const char * /*join_column*/, const utils::foreign_attributes &/*attr*/, std::enable_if_t<!object::is_object_ptr<typename CollectionType::value_type>::value> * = nullptr) {
}
template<class CollectionType>
void on_has_many(const char * /*id*/, CollectionType &, const char * /*join_column*/, const utils::foreign_attributes &/*attr*/, std::enable_if_t<!object::is_object_ptr<typename CollectionType::value_type>::value> * = nullptr);
template <class CollectionType>
void on_has_many_to_many(const char *id, CollectionType &, const char * /*join_column*/, const char * /*inverse_join_column*/, const utils::foreign_attributes &attr);
template<class CollectionType>
void on_has_many_to_many(const char *, CollectionType &, const utils::foreign_attributes &attr);
@ -158,6 +157,25 @@ void query_result_impl::on_has_many(const char *, CollectionType &cont, const ch
}
}
}
template <class CollectionType>
void query_result_impl::on_has_many(const char *id, CollectionType &cont, const char *join_column, const utils::foreign_attributes &attr, std::enable_if_t<!object::is_object_ptr<typename CollectionType::value_type>::value> *) {
using value_type = typename CollectionType::value_type;
auto object_resolver = resolver_->object_resolver<value_type>();
auto resolver = resolver_->collection_resolver<typename CollectionType::value_type>(result_type_, join_column);
if (attr.fetch() == utils::fetch_type::Lazy) {
cont.reset(std::make_shared<object::collection_proxy<typename CollectionType::value_type>>(resolver, current_pk_));
} else {
if (initialized_collections_.insert({result_type_, typeid(typename CollectionType::value_type), std::string{join_column}}).second) {
cont.reset(std::make_shared<object::collection_proxy<typename CollectionType::value_type>>(resolver, std::vector<typename CollectionType::value_type>()));
}
// read a single value
value_type value;
utils::data_type_traits<value_type>::read_value(*reader_, id, column_index_++, value, sizeof(value_type));
cont.push_back(value);
}
}
template <class CollectionType>
void query_result_impl::on_has_many_to_many(const char *id, CollectionType &cont, const char *join_column, const char *, const utils::foreign_attributes &attr) {

View File

@ -44,13 +44,13 @@ char* gettimestamp(char* const buffer, const size_t size) {
}
std::map<log_level, std::string> log_domain::level_strings = { /* NOLINT */
{ log_level::Fatal, "Fatal" },
{ log_level::Debug, "Debug" },
{ log_level::Info, "Info" },
{ log_level::Warn, "Warn" },
{ log_level::Error, "Error" },
{ log_level::Trace, "Trace" },
{ log_level::All, "All" }
{ log_level::Fatal, "FATAL" },
{ log_level::Debug, "DEBUG" },
{ log_level::Info, "INFO" },
{ log_level::Warn, "WARN" },
{ log_level::Error, "ERROR" },
{ log_level::Trace, "TRACE" },
{ log_level::All, "ALL" }
};
log_domain::log_domain(std::string name, const log_level_range log_range)

View File

@ -113,15 +113,13 @@ void default_max_log_level(const log_level max_lvl)
log_manager::max_default_log_level(max_lvl);
}
void domain_min_log_level(const std::string &name, const log_level min_lvl)
{
void domain_min_log_level(const std::string &name, const log_level min_lvl) {
if (const auto domain = log_manager::instance().find_domain(name)) {
domain->min_log_level(min_lvl);
}
}
void domain_max_log_level(const std::string &name, const log_level max_lvl)
{
void domain_max_log_level(const std::string &name, const log_level max_lvl) {
if (const auto domain = log_manager::instance().find_domain(name)) {
domain->max_log_level(max_lvl);
}

View File

@ -133,14 +133,14 @@ TEST_CASE("Test log rotating file sink", "[logger][log][rotate_file_sink]") {
}
TEST_CASE("Test log level range", "[logger][level][range]") {
REQUIRE(log_level::Info == log_manager::min_default_log_level());
REQUIRE(log_level::Fatal == log_manager::max_default_log_level());
REQUIRE(log_level::Fatal == log_manager::min_default_log_level());
REQUIRE(log_level::Info == log_manager::max_default_log_level());
default_min_log_level(log_level::Debug);
default_max_log_level(log_level::Error);
default_min_log_level(log_level::Error);
default_max_log_level(log_level::Debug);
REQUIRE(log_level::Debug == log_manager::min_default_log_level());
REQUIRE(log_level::Error == log_manager::max_default_log_level());
REQUIRE(log_level::Error == log_manager::min_default_log_level());
REQUIRE(log_level::Debug == log_manager::max_default_log_level());
log_level_range llr;
llr.min_level = log_level::Debug;
@ -150,11 +150,11 @@ TEST_CASE("Test log level range", "[logger][level][range]") {
REQUIRE(log_level::Debug == ld.min_log_level());
REQUIRE(log_level::Trace == ld.max_log_level());
ld.min_log_level(log_level::Info);
ld.max_log_level(log_level::Error);
ld.min_log_level(log_level::Error);
ld.max_log_level(log_level::Info);
REQUIRE(log_level::Info == ld.min_log_level());
REQUIRE(log_level::Error == ld.max_log_level());
REQUIRE(log_level::Error == ld.min_log_level());
REQUIRE(log_level::Info == ld.max_log_level());
}
TEST_CASE("Test basic logger functions", "[logger][basic]") {

View File

@ -31,7 +31,7 @@ using namespace matador::query;
using namespace matador::utils;
using namespace matador::sql;
using namespace matador::test;
using namespace matador::query::meta;
using namespace matador::query::meta;
TEST_CASE("Create sql query data for entity with eager has one", "[query][entity][builder]") {
using namespace matador::test;
@ -331,7 +331,7 @@ TEST_CASE("Create sql query data for entity with eager many to many (inverse par
REQUIRE(cond == R"("t01"."id" = ?)");
}
TEST_CASE("Test eager relationship", "[session][eager]") {
TEST_CASE("Test eager relationship", "[query][entity][builder]") {
using namespace matador::test;
backend_provider::instance().register_backend("noop", std::make_unique<orm::test_backend_service>());
connection db("noop://noop.db");

View File

@ -249,8 +249,8 @@ TEST_CASE_METHOD(QueryFixture, "Test create, insert and select a blob column", "
TEST_CASE_METHOD(QueryFixture, "Test select statement with join_left", "[query][statement][join_left]") {
const auto ap = table("airplane").as("ap");
const auto f = table("flight").as("f");
const class matador::query::table_column col1 = {&f, "airplane_id"};
const class matador::query::table_column col2 = {&ap, "id"};
const table_column col1 = {&f, "airplane_id"};
const table_column col2 = {&ap, "id"};
const auto result = query::select({"f.id", "ap.brand", "f.pilot_name"})
.from(table{"flight"}.as("f"))
.join_left(table{"airplane"}.as("ap"))