diff --git a/src/LibUtils.hpp b/src/LibUtils.hpp index c1c560a75da3ea3a546991da75aec4329221fc4e..1fabc1b7c191bfb5003a5217e0d15118025826c3 100644 --- a/src/LibUtils.hpp +++ b/src/LibUtils.hpp @@ -59,7 +59,7 @@ std::ostream &operator<<(std::ostream &os, Tango::CmdArgType type); std::ostream &operator<<(std::ostream &os, Tango::AttrQuality quality); // SPDLOG config and setup -const string LibLoggerName = "hdbpp_internal"; +const string LibLoggerName = "hdbpp"; struct LogConfigurator { @@ -68,10 +68,25 @@ struct LogConfigurator static void setLoggingLevel(spdlog::level::level_enum level); }; +// get the file name from the __FILE__ variable for error messages +constexpr auto* getFileName(const char* const path) +{ + const auto* start_position = path; + + for (const auto* current_character = path; *current_character != '\0'; ++current_character) + if (*current_character == '\\' || *current_character == '/') + start_position = current_character; + + if (start_position != path) + ++start_position; + + return start_position; +} + // Macros to get the location for reporting errors #define S1(x) #x #define S2(x) S1(x) -#define LOCATION_INFO string(__func__) + ":" S2(__LINE__) +#define LOCATION_INFO string(getFileName(__FILE__)) + ":" + string(__func__) + ":" S2(__LINE__) }; // namespace hdbpp_internal #endif // _LIBUTILS_H diff --git a/test/AttributeTraitsTests.cpp b/test/AttributeTraitsTests.cpp index 72a9d83c364e2e30a092555a584ed4343b477616..697c78039ce887dd18c3e2d219d9356264cfff5c 100644 --- a/test/AttributeTraitsTests.cpp +++ b/test/AttributeTraitsTests.cpp @@ -20,11 +20,15 @@ #include "AttributeTraits.hpp" #include "catch2/catch.hpp" +#include "LibUtils.hpp" + using namespace std; using namespace hdbpp_internal; SCENARIO("Attribute format returns expected results", "[attribute-traits]") { + cout << LOCATION_INFO << endl; + GIVEN("Constructed AttributeTraits as an Array") { AttributeTraits traits {Tango::READ, Tango::SPECTRUM, Tango::DEV_BOOLEAN};