stabilized logger classes
This commit is contained in:
@@ -18,8 +18,7 @@ using namespace matador::logger;
|
||||
|
||||
namespace filehelper {
|
||||
|
||||
class std_stream_switcher
|
||||
{
|
||||
class std_stream_switcher {
|
||||
public:
|
||||
explicit std_stream_switcher(FILE *str, const char* redirect)
|
||||
: stream(str) {
|
||||
@@ -56,8 +55,6 @@ TEST_CASE("Test log file sink", "[logger][log][file_sink]") {
|
||||
|
||||
REQUIRE(matador::os::exists("test.txt"));
|
||||
|
||||
// UNIT_ASSERT_EQUAL("test.txt", test.path());
|
||||
|
||||
test.close();
|
||||
|
||||
if (::remove("test.txt") == -1) {
|
||||
@@ -136,28 +133,28 @@ TEST_CASE("Test log rotating file sink", "[logger][log][rotate_file_sink]") {
|
||||
}
|
||||
|
||||
TEST_CASE("Test log level range", "[logger][level][range]") {
|
||||
REQUIRE(log_level::LVL_INFO == log_manager::min_default_log_level());
|
||||
REQUIRE(log_level::LVL_FATAL == log_manager::max_default_log_level());
|
||||
REQUIRE(log_level::Info == log_manager::min_default_log_level());
|
||||
REQUIRE(log_level::Fatal == log_manager::max_default_log_level());
|
||||
|
||||
default_min_log_level(log_level::LVL_DEBUG);
|
||||
default_max_log_level(log_level::LVL_ERROR);
|
||||
default_min_log_level(log_level::Debug);
|
||||
default_max_log_level(log_level::Error);
|
||||
|
||||
REQUIRE(log_level::LVL_DEBUG == log_manager::min_default_log_level());
|
||||
REQUIRE(log_level::LVL_ERROR == log_manager::max_default_log_level());
|
||||
REQUIRE(log_level::Debug == log_manager::min_default_log_level());
|
||||
REQUIRE(log_level::Error == log_manager::max_default_log_level());
|
||||
|
||||
log_level_range llr;
|
||||
llr.min_level = log_level::LVL_DEBUG;
|
||||
llr.max_level = log_level::LVL_TRACE;
|
||||
llr.min_level = log_level::Debug;
|
||||
llr.max_level = log_level::Trace;
|
||||
log_domain ld("test", llr);
|
||||
|
||||
REQUIRE(log_level::LVL_DEBUG == ld.min_log_level());
|
||||
REQUIRE(log_level::LVL_TRACE == ld.max_log_level());
|
||||
REQUIRE(log_level::Debug == ld.min_log_level());
|
||||
REQUIRE(log_level::Trace == ld.max_log_level());
|
||||
|
||||
ld.min_log_level(log_level::LVL_INFO);
|
||||
ld.max_log_level(log_level::LVL_ERROR);
|
||||
ld.min_log_level(log_level::Info);
|
||||
ld.max_log_level(log_level::Error);
|
||||
|
||||
REQUIRE(log_level::LVL_INFO == ld.min_log_level());
|
||||
REQUIRE(log_level::LVL_ERROR == ld.max_log_level());
|
||||
REQUIRE(log_level::Info == ld.min_log_level());
|
||||
REQUIRE(log_level::Error == ld.max_log_level());
|
||||
}
|
||||
|
||||
TEST_CASE("Test basic logger functions", "[logger][basic]") {
|
||||
@@ -205,8 +202,8 @@ TEST_CASE("Test basic logger functions", "[logger][basic]") {
|
||||
}
|
||||
|
||||
TEST_CASE("Test logging", "[logger][logging]") {
|
||||
domain_min_log_level("default", log_level::LVL_FATAL);
|
||||
domain_max_log_level("default", log_level::LVL_TRACE);
|
||||
domain_min_log_level("default", log_level::Fatal);
|
||||
domain_max_log_level("default", log_level::Trace);
|
||||
|
||||
auto logger = create_logger("test");
|
||||
|
||||
@@ -230,7 +227,7 @@ TEST_CASE("Test logging", "[logger][logging]") {
|
||||
logger.trace("tracing something %s", "important");
|
||||
logger.error("big error");
|
||||
logger.error("big error %s", "important");
|
||||
log(log_level::LVL_ERROR, "test", "global log test %d", 4711);
|
||||
log(log_level::Error, "test", "global log test %d", 4711);
|
||||
|
||||
logsink->close();
|
||||
|
||||
@@ -308,43 +305,43 @@ TEST_CASE("Test log stderr", "[logger][logging][stderr]") {
|
||||
TEST_CASE("Test log levels", "[logger][levels]") {
|
||||
std::stringstream out;
|
||||
|
||||
out << log_level::LVL_ERROR;
|
||||
out << log_level::Error;
|
||||
|
||||
REQUIRE("ERROR" == out.str());
|
||||
|
||||
out.str("");
|
||||
out.clear();
|
||||
out << log_level::LVL_DEBUG;
|
||||
out << log_level::Debug;
|
||||
|
||||
REQUIRE("DEBUG" == out.str());
|
||||
|
||||
out.str("");
|
||||
out.clear();
|
||||
out << log_level::LVL_INFO;
|
||||
out << log_level::Info;
|
||||
|
||||
REQUIRE("INFO" == out.str());
|
||||
|
||||
out.str("");
|
||||
out.clear();
|
||||
out << log_level::LVL_FATAL;
|
||||
out << log_level::Fatal;
|
||||
|
||||
REQUIRE("FATAL" == out.str());
|
||||
|
||||
out.str("");
|
||||
out.clear();
|
||||
out << log_level::LVL_TRACE;
|
||||
out << log_level::Trace;
|
||||
|
||||
REQUIRE("TRACE" == out.str());
|
||||
|
||||
out.str("");
|
||||
out.clear();
|
||||
out << log_level::LVL_WARN;
|
||||
out << log_level::Warn;
|
||||
|
||||
REQUIRE("WARN" == out.str());
|
||||
|
||||
out.str("");
|
||||
out.clear();
|
||||
out << log_level::LVL_ALL;
|
||||
out << log_level::All;
|
||||
|
||||
REQUIRE("ALL" == out.str());
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "matador/utils/foreign_attributes.hpp"
|
||||
|
||||
#include "matador/object/object_ptr.hpp"
|
||||
#include "matador/object/collection.hpp"
|
||||
#include "matador/object/many_to_many_relation.hpp"
|
||||
|
||||
#include <utility>
|
||||
@@ -16,7 +17,7 @@ struct course;
|
||||
struct student {
|
||||
unsigned int id{};
|
||||
std::string name;
|
||||
std::vector<object::object_ptr<course> > courses;
|
||||
object::collection<object::object_ptr<course> > courses;
|
||||
|
||||
student() = default;
|
||||
|
||||
@@ -37,7 +38,7 @@ struct student {
|
||||
struct course {
|
||||
unsigned int id{};
|
||||
std::string title;
|
||||
std::vector<object::object_ptr<student> > students;
|
||||
object::collection<object::object_ptr<student> > students;
|
||||
|
||||
course() = default;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user