Skip to content

Commit 6e39c92

Browse files
committed
fix: update test logging level to Debug in nlog_module_test
1 parent c1f55a1 commit 6e39c92

File tree

4 files changed

+28
-17
lines changed

4 files changed

+28
-17
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ if(NEKO_LOG_BUILD_TESTS)
135135
message(STATUS "NekoLog module tests enabled (MSVC only)")
136136

137137
add_executable(nlog_module_test tests/nlog_module_test.cpp)
138-
target_link_libraries(nlog_module_test PRIVATE NekoLog_module GTest::gtest GTest::gtest_main)
138+
target_link_libraries(nlog_module_test PRIVATE Neko::Log::Module GTest::gtest GTest::gtest_main)
139139
target_compile_features(nlog_module_test PRIVATE cxx_std_20)
140140
gtest_discover_tests(nlog_module_test)
141141
else()

include/neko/log/neko.log.cppm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ import neko.schema;
4343

4444
export {
4545
#include "nlog.hpp"
46-
}
46+
}

include/neko/log/nlog.hpp

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
/* ===================== */
1717

1818
#if !__has_include(<format>)
19-
#error "Neko logging Cannot find header <format>"
19+
#error "Neko logging Cannot find header <format>"
2020
#endif
2121

22-
#include <version>
2322
#include <format>
23+
#include <version>
2424

2525
#if !defined(__cpp_lib_format) || __cpp_lib_format < 201907L
26-
#error "Neko logging requires <format> support"
26+
#error "Neko logging requires <format> support"
2727
#endif
2828

2929
/* ===================== */
@@ -145,7 +145,11 @@ namespace neko::log {
145145
std::lock_guard<std::mutex> lock(namesMutex);
146146
threadNames.clear();
147147
}
148-
} inline threadNameManager;
148+
}
149+
#if !defined(NEKO_LOG_ENABLE_MODULE) || (NEKO_LOG_ENABLE_MODULE == false)
150+
inline
151+
#endif
152+
threadNameManager;
149153

150154
/**
151155
* @brief Log record structure
@@ -299,8 +303,8 @@ namespace neko::log {
299303
public:
300304
explicit ConsoleAppender(std::unique_ptr<IFormatter> formatter = std::make_unique<DefaultFormatter>())
301305
: formatter(std::move(formatter)) {
302-
preOutput();
303-
}
306+
preOutput();
307+
}
304308

305309
explicit ConsoleAppender(Level level, std::unique_ptr<IFormatter> formatter = std::make_unique<DefaultFormatter>())
306310
: formatter(std::move(formatter)) {
@@ -595,29 +599,33 @@ namespace neko::log {
595599
// === formatted message logging ===
596600

597601
template <typename... Args>
598-
void debug(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) {
602+
void debug(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) {
599603
auto message = std::format(fmt, std::forward<Args>(args)...);
600604
log(Level::Debug, message, location);
601605
}
602606

603607
template <typename... Args>
604-
void info(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) {
608+
void info(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) {
605609
auto message = std::format(fmt, std::forward<Args>(args)...);
606610
log(Level::Info, message, location);
607611
}
608612

609613
template <typename... Args>
610-
void warn(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) {
614+
void warn(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) {
611615
auto message = std::format(fmt, std::forward<Args>(args)...);
612616
log(Level::Warn, message, location);
613617
}
614618

615619
template <typename... Args>
616-
void error(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) {
620+
void error(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) {
617621
auto message = std::format(fmt, std::forward<Args>(args)...);
618622
log(Level::Error, message, location);
619623
}
620-
} inline logger;
624+
}
625+
#if !defined(NEKO_LOG_ENABLE_MODULE) || (NEKO_LOG_ENABLE_MODULE == false)
626+
inline
627+
#endif
628+
logger;
621629

622630
// === Convenience functions ===
623631

@@ -697,22 +705,22 @@ namespace neko::log {
697705
}
698706

699707
template <typename... Args>
700-
void debug(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) {
708+
void debug(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) {
701709
auto message = std::format(fmt, std::forward<Args>(args)...);
702710
logger.debug(message, location);
703711
}
704712
template <typename... Args>
705-
void info(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) {
713+
void info(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) {
706714
auto message = std::format(fmt, std::forward<Args>(args)...);
707715
logger.info(message, location);
708716
}
709717
template <typename... Args>
710-
void warn(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) {
718+
void warn(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) {
711719
auto message = std::format(fmt, std::forward<Args>(args)...);
712720
logger.warn(message, location);
713721
}
714722
template <typename... Args>
715-
void error(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) {
723+
void error(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) {
716724
auto message = std::format(fmt, std::forward<Args>(args)...);
717725
logger.error(message, location);
718726
}

tests/nlog_module_test.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ TEST(NLogModuleTest, BasicAPI) {
234234
auto* testAppenderPtr = testAppender.get();
235235
log::addAppender(std::move(testAppender));
236236

237+
// Set log level to Debug to ensure all messages are logged
238+
log::setLevel(log::Level::Debug);
239+
237240
// Test all log levels with simple messages
238241
log::debug("Debug message");
239242
log::info("Info message");

0 commit comments

Comments
 (0)