Skip to content

Commit

Permalink
made Logger::name() public, added test case
Browse files Browse the repository at this point in the history
  • Loading branch information
usefulcat authored and odygrd committed Dec 1, 2023
1 parent b356340 commit e4826be
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
10 changes: 5 additions & 5 deletions quill/include/quill/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ class alignas(detail::CACHE_LINE_ALIGNED) Logger
this->template log<decltype(anonymous_log_message_info)>(LogLevel::None, QUILL_FMT_STRING(""));
}

/**
* @return The name of the logger
*/
QUILL_NODISCARD std::string const& name() const noexcept { return _logger_details.name(); }

private:
friend class detail::LoggerCollection;
friend class detail::LogManager;
Expand Down Expand Up @@ -371,11 +376,6 @@ class alignas(detail::CACHE_LINE_ALIGNED) Logger
return _is_invalidated.load(std::memory_order_acquire);
}

/**
* @return The name of the logger
*/
QUILL_NODISCARD std::string const& name() const noexcept { return _logger_details.name(); }

private:
detail::LoggerDetails _logger_details;
TimestampClock* _custom_timestamp_clock{nullptr}; /* A non owned pointer to a custom timestamp clock, valid only when provided */
Expand Down
15 changes: 14 additions & 1 deletion quill/test/LoggerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,17 @@ TEST_CASE("logger_should_log")
REQUIRE_UNARY_FALSE(logger_collection.get_logger("logger_1")->should_log<LogLevel::Critical>());
}

TEST_SUITE_END();
/***/
TEST_CASE("logger_name")
{
Config cfg;
ThreadContextCollection tc{cfg};
HandlerCollection hc;

LoggerCollection logger_collection{cfg, tc, hc};

Logger* logger_1 = logger_collection.create_logger("logger_1", TimestampClockType::Tsc, nullptr);
REQUIRE_EQ(logger_1->name(), "logger_1");
}

TEST_SUITE_END();

0 comments on commit e4826be

Please sign in to comment.