Skip to content

Commit 2d5c728

Browse files
committed
move x-macro to def/undef headers
1 parent 3375c8d commit 2d5c728

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

include/nbl/logging_macros.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifdef __GIT_INFO_H_INCLUDED__
2+
// when "git_info.h" is included
3+
# define LOG(SEVERITY, FORMAT, ...) LOG_FUNCTION(FORMAT" [%s][%s - %s:%d]", SEVERITY, __VA_ARGS__, nbl::gtml::nabla_git_info.commitShortHash, __FUNCTION__, __FILE__, __LINE__);
4+
# define LOG_ERROR(FORMAT, ...) LOG(nbl::system::ILogger::ELL_ERROR, FORMAT, __VA_ARGS__)
5+
#else
6+
# define LOG(SEVERITY, FORMAT, ...) LOG_FUNCTION(FORMAT" [%s - %s:%d]", SEVERITY, __VA_ARGS__, __FUNCTION__, __FILE__, __LINE__);
7+
# define LOG_ERROR(FORMAT, ...) LOG(nbl::system::ILogger::ELL_ERROR, FORMAT, __VA_ARGS__)
8+
#endif

include/nbl/undef_logging_macros.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#undef LOG
2+
#undef LOG_ERROR
3+
#undef LOG_FUNCTION

include/nbl/video/ILogicalDevice.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
#include "nbl/video/CJITIncludeLoader.h"
1616

1717
#include "git_info.h"
18-
1918
#define LOG_FUNCTION m_logger.log
20-
#define LOG_ERROR(FORMAT, ...) LOG_FUNCTION(FORMAT" [%s][%s - %s:%d]", nbl::system::ILogger::ELL_ERROR, __VA_ARGS__, nbl::gtml::nabla_git_info.commitShortHash , __FUNCTION__, __FILE__, __LINE__);
19+
#include "nbl/logging_macros.h"
2120

2221
namespace nbl::video
2322
{
@@ -1469,6 +1468,5 @@ inline bool ILogicalDevice::validateMemoryBarrier(const uint32_t queueFamilyInde
14691468

14701469
} // namespace nbl::video
14711470

1472-
#undef LOG_FUNCTION
1473-
#undef LOG_ERROR
1471+
#include "nbl/undef_logging_macros.h"
14741472
#endif //_NBL_VIDEO_I_LOGICAL_DEVICE_H_INCLUDED_

src/nbl/video/ILogicalDevice.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#include "nbl/video/IPhysicalDevice.h"
22

33
#include "git_info.h"
4+
#define LOG_FUNCTION m_logger.log
5+
#include "nbl/logging_macros.h"
46

57
using namespace nbl;
68
using namespace nbl::video;
79

810

9-
#define LOG_FUNCTION m_logger.log
10-
#define LOG_ERROR(FORMAT, ...) LOG_FUNCTION(FORMAT" [%s][%s - %s:%d]", nbl::system::ILogger::ELL_ERROR, __VA_ARGS__, nbl::gtml::nabla_git_info.commitShortHash , __FUNCTION__, __FILE__, __LINE__);
11-
1211
ILogicalDevice::ILogicalDevice(core::smart_refctd_ptr<const IAPIConnection>&& api, const IPhysicalDevice* const physicalDevice, const SCreationParams& params, const bool runningInRenderdoc)
1312
: m_api(api), m_physicalDevice(physicalDevice), m_enabledFeatures(params.featuresToEnable), m_compilerSet(params.compilerSet),
1413
m_logger(m_physicalDevice->getDebugCallback() ? m_physicalDevice->getDebugCallback()->getLogger():nullptr)
@@ -941,4 +940,6 @@ bool ILogicalDevice::createGraphicsPipelines(
941940
return false;
942941
}
943942
return true;
944-
}
943+
}
944+
945+
#include "nbl/undef_logging_macros.h"

src/nbl/video/IQueue.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
#include "nbl/video/TimelineEventHandlers.h"
55

66
#include "git_info.h"
7-
87
#define LOG_FUNCTION logger->log
9-
#define LOG(SEVERITY, FORMAT, ...) LOG_FUNCTION(FORMAT" [%s][%s - %s:%d]", SEVERITY, __VA_ARGS__, nbl::gtml::nabla_git_info.commitShortHash , __FUNCTION__, __FILE__, __LINE__);
10-
#define LOG_ERROR(FORMAT, ...) LOG(nbl::system::ILogger::ELL_ERROR, FORMAT, __VA_ARGS__)
8+
#include "nbl/logging_macros.h"
119

1210
namespace nbl::video
1311
{
@@ -143,4 +141,6 @@ uint32_t IQueue::cullResources(const ISemaphore* sema)
143141
return m_submittedResources->poll().eventsLeft;
144142
}
145143

146-
}
144+
} // namespace nbl::video
145+
146+
#include "nbl/undef_logging_macros.h"

0 commit comments

Comments
 (0)