Updated logging definitions to ensure it works using dynamic and static config

This commit is contained in:
Alejandro Saucedo 2020-09-04 07:01:58 +01:00
parent 1286da2179
commit c15a14d2b2
6 changed files with 31 additions and 31 deletions

View file

@ -208,6 +208,8 @@ SPDLOG is the preferred logging library, however by default Vulkan Kompute runs
You can choose to build with or without SPDLOG by using the cmake flag `KOMPUTE_OPT_ENABLE_SPDLOG`.
Finally, remember that you will still need to set both the compile time log level with `SPDLOG_ACTIVE_LEVEL`, and the runtime log level with `spdlog::set_level(spdlog::level::debug);`.
## Motivations

View file

@ -3,11 +3,13 @@
#include <vulkan/vulkan.hpp>
// SPDLOG_ACTIVE_LEVEL must be defined before spdlog.h import
#if DEBUG
#ifndef SPDLOG_ACTIVE_LEVEL
#if !defined(SPDLOG_ACTIVE_LEVEL)
#if RELEASE
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
#else
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG
#endif
#endif
#endif
#ifndef KOMPUTE_LOG_OVERRIDE
#if KOMPUTE_ENABLE_SPDLOG

View file

@ -18,8 +18,10 @@ Tensor::Tensor()
Tensor::Tensor(std::vector<float> data, TensorTypes tensorType)
{
#if DEBUG
SPDLOG_DEBUG(
"Kompute Tensor constructor data: {}, and type: {}", data, tensorType);
#endif
this->mData = data;
this->mShape = { static_cast<uint32_t>(data.size()) };

View file

@ -3,11 +3,13 @@
#include <vulkan/vulkan.hpp>
// SPDLOG_ACTIVE_LEVEL must be defined before spdlog.h import
#if !defined(SPDLOG_ACTIVE_LEVEL)
#if DEBUG
#ifndef SPDLOG_ACTIVE_LEVEL
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG
#endif
#else
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
#endif
#endif
#ifndef KOMPUTE_LOG_OVERRIDE
#if KOMPUTE_ENABLE_SPDLOG

View file

@ -15,8 +15,8 @@ target_include_directories(
)
target_link_libraries(test_kompute PRIVATE
GTest::gtest
GTest::gtest_main)
GTest::gtest
GTest::gmock)
target_link_libraries(test_kompute PRIVATE kompute)

View file

@ -1,24 +1,16 @@
//#define CATCH_CONFIG_RUNNER
//
//// clang-format: SPDLOG_ACTIVE_LEVEL must be defined before spdlog.h import
//#if DEBUG
//#ifndef SPDLOG_ACTIVE_LEVEL
//#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG
//#endif
//#endif
//
////#include <spdlog/spdlog.h>
////// clang-format: ranges.h must come after spdlog.h
////#include <fmt/ranges.h>
//
//#include "catch2/catch.hpp"
//
//int main( int argc, char* argv[] ) {
//
// int result = Catch::Session().run( argc, argv );
//
// // global clean-up...
//
// return result;
//}
//
#include <gmock/gmock.h>
#include <kompute/Kompute.hpp>
int main(int argc, char *argv[]) {
testing::InitGoogleTest(&argc, argv);
testing::InitGoogleMock(&argc, argv);
#if KOMPUTE_ENABLE_SPDLOG
spdlog::set_level(static_cast<spdlog::level::level_enum>(SPDLOG_ACTIVE_LEVEL));
spdlog::error("default active level {}", SPDLOG_ACTIVE_LEVEL);
#endif
return RUN_ALL_TESTS();
}