Skip to content
Snippets Groups Projects
Commit 4e8e7c53 authored by Stuart Mark James's avatar Stuart Mark James
Browse files

Tango exceptions now include filename where the error is raised

parent b8a4401a
Branches
Tags
No related merge requests found
...@@ -59,7 +59,7 @@ std::ostream &operator<<(std::ostream &os, Tango::CmdArgType type); ...@@ -59,7 +59,7 @@ std::ostream &operator<<(std::ostream &os, Tango::CmdArgType type);
std::ostream &operator<<(std::ostream &os, Tango::AttrQuality quality); std::ostream &operator<<(std::ostream &os, Tango::AttrQuality quality);
// SPDLOG config and setup // SPDLOG config and setup
const string LibLoggerName = "hdbpp_internal"; const string LibLoggerName = "hdbpp";
struct LogConfigurator struct LogConfigurator
{ {
...@@ -68,10 +68,25 @@ struct LogConfigurator ...@@ -68,10 +68,25 @@ struct LogConfigurator
static void setLoggingLevel(spdlog::level::level_enum level); 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 // Macros to get the location for reporting errors
#define S1(x) #x #define S1(x) #x
#define S2(x) S1(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 }; // namespace hdbpp_internal
#endif // _LIBUTILS_H #endif // _LIBUTILS_H
...@@ -20,11 +20,15 @@ ...@@ -20,11 +20,15 @@
#include "AttributeTraits.hpp" #include "AttributeTraits.hpp"
#include "catch2/catch.hpp" #include "catch2/catch.hpp"
#include "LibUtils.hpp"
using namespace std; using namespace std;
using namespace hdbpp_internal; using namespace hdbpp_internal;
SCENARIO("Attribute format returns expected results", "[attribute-traits]") SCENARIO("Attribute format returns expected results", "[attribute-traits]")
{ {
cout << LOCATION_INFO << endl;
GIVEN("Constructed AttributeTraits as an Array") GIVEN("Constructed AttributeTraits as an Array")
{ {
AttributeTraits traits {Tango::READ, Tango::SPECTRUM, Tango::DEV_BOOLEAN}; AttributeTraits traits {Tango::READ, Tango::SPECTRUM, Tango::DEV_BOOLEAN};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment