In very specific contexts, it's possible that a `bt2c::Logger` reference
is a dependent type, for example:
template <typename T>
struct X
{
const bt2c::Logger& logger() const noexcept
{
return /* some logger reference */;
}
void log()
{
BT_CPPLOGI_SPEC(this->logger(), "Hello!");
}
};
In that case, the BT_CPPLOGI_SPEC() macro eventually expands to
something like:
this->logger().log<bt2c::Logger::Level::Info,
false>(__FILE__, __func__, __LINE__, "Hello!");
`this->logger()` is basically `X<T>::logger()`. Therefore, from the
log() method template point of view, the type of `this` depends on `T`,
that is, it's a dependent name. This example above won't build.
In that case, we need the `template` keyword to call the method:
this->logger().template log<bt2c::Logger::Level::Info,
false>(__FILE__, __func__,
__LINE__, "Hello!");
Using the `template` keyword or not would normally be a per-call
decision, but those BT_CPPLOG*() macros do the call themselves.
Knowing this, this patch adds the `template` keyword to all the logging
method calls from the BT_CPPLOG*() macros, just in case.
The current project builds because it doesn't have this specific
situation, but it could happen in the future.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I2847105746825d94cf71ed3abbd56fac0f160a2d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12477
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
#define BT_CPPLOG_EX(_lvl, _logger, _fmt, ...) \
do { \
if (G_UNLIKELY((_logger).wouldLog(_lvl))) { \
#define BT_CPPLOG_EX(_lvl, _logger, _fmt, ...) \
do { \
if (G_UNLIKELY((_logger).wouldLog(_lvl))) { \
- (_logger).log<(_lvl), false>(__FILE__, __func__, __LINE__, (_fmt), ##__VA_ARGS__); \
+ (_logger).template log<(_lvl), false>(__FILE__, __func__, __LINE__, (_fmt), \
+ ##__VA_ARGS__); \
* Calls logStr() on `_logger` to log using the level `_lvl`.
*/
#define BT_CPPLOG_STR_EX(_lvl, _logger, _msg) \
* Calls logStr() on `_logger` to log using the level `_lvl`.
*/
#define BT_CPPLOG_STR_EX(_lvl, _logger, _msg) \
- (_logger).logStr<(_lvl), false>(__FILE__, __func__, __LINE__, (_msg))
+ (_logger).template logStr<(_lvl), false>(__FILE__, __func__, __LINE__, (_msg))
/*
* BT_CPPLOG_STR_EX() with specific logging levels.
/*
* BT_CPPLOG_STR_EX() with specific logging levels.
#define BT_CPPLOG_MEM_EX(_lvl, _logger, _memData, _fmt, ...) \
do { \
if (G_UNLIKELY((_logger).wouldLog(_lvl))) { \
#define BT_CPPLOG_MEM_EX(_lvl, _logger, _memData, _fmt, ...) \
do { \
if (G_UNLIKELY((_logger).wouldLog(_lvl))) { \
- (_logger).logMem<(_lvl)>(__FILE__, __func__, __LINE__, (_memData), (_fmt), \
- ##__VA_ARGS__); \
+ (_logger).template logMem<(_lvl)>(__FILE__, __func__, __LINE__, (_memData), (_fmt), \
+ ##__VA_ARGS__); \
* Calls logMemStr() on `_logger` to log using the level `_lvl`.
*/
#define BT_CPPLOG_MEM_STR_EX(_lvl, _logger, _memData, _msg) \
* Calls logMemStr() on `_logger` to log using the level `_lvl`.
*/
#define BT_CPPLOG_MEM_STR_EX(_lvl, _logger, _memData, _msg) \
- (_logger).logMemStr<(_lvl)>(__FILE__, __func__, __LINE__, (_memData), (_msg))
+ (_logger).template logMemStr<(_lvl)>(__FILE__, __func__, __LINE__, (_memData), (_msg))
/*
* BT_CPPLOG_MEM_STR_EX() with specific logging levels.
/*
* BT_CPPLOG_MEM_STR_EX() with specific logging levels.
#define BT_CPPLOG_ERRNO_EX(_lvl, _logger, _initMsg, _fmt, ...) \
do { \
if (G_UNLIKELY((_logger).wouldLog(_lvl))) { \
#define BT_CPPLOG_ERRNO_EX(_lvl, _logger, _initMsg, _fmt, ...) \
do { \
if (G_UNLIKELY((_logger).wouldLog(_lvl))) { \
- (_logger).logErrno<(_lvl), false>(__FILE__, __func__, __LINE__, (_initMsg), (_fmt), \
- ##__VA_ARGS__); \
+ (_logger).template logErrno<(_lvl), false>(__FILE__, __func__, __LINE__, (_initMsg), \
+ (_fmt), ##__VA_ARGS__); \
* initial message `_initMsg`.
*/
#define BT_CPPLOG_ERRNO_STR_EX(_lvl, _logger, _initMsg, _msg) \
* initial message `_initMsg`.
*/
#define BT_CPPLOG_ERRNO_STR_EX(_lvl, _logger, _initMsg, _msg) \
- (_logger).logErrnoStr<(_lvl), false>(__FILE__, __func__, __LINE__, (_initMsg), (_msg))
+ (_logger).template logErrnoStr<(_lvl), false>(__FILE__, __func__, __LINE__, (_initMsg), (_msg))
/*
* BT_CPPLOG_ERRNO_STR_EX() with specific logging levels.
/*
* BT_CPPLOG_ERRNO_STR_EX() with specific logging levels.
* append a cause to the error of the current thread.
*/
#define BT_CPPLOGE_APPEND_CAUSE_SPEC(_logger, _fmt, ...) \
* append a cause to the error of the current thread.
*/
#define BT_CPPLOGE_APPEND_CAUSE_SPEC(_logger, _fmt, ...) \
- (_logger).log<bt2c::Logger::Level::Error, true>(__FILE__, __func__, __LINE__, (_fmt), \
- ##__VA_ARGS__)
+ (_logger).template log<bt2c::Logger::Level::Error, true>(__FILE__, __func__, __LINE__, (_fmt), \
+ ##__VA_ARGS__)
/*
* BT_CPPLOGE_APPEND_CAUSE_SPEC() using the default logger.
/*
* BT_CPPLOGE_APPEND_CAUSE_SPEC() using the default logger.
* append a cause to the error of the current thread.
*/
#define BT_CPPLOGE_STR_APPEND_CAUSE_SPEC(_logger, _msg) \
* append a cause to the error of the current thread.
*/
#define BT_CPPLOGE_STR_APPEND_CAUSE_SPEC(_logger, _msg) \
- (_logger).logStr<bt2c::Logger::Level::Error, true>(__FILE__, __func__, __LINE__, (_msg))
+ (_logger).template logStr<bt2c::Logger::Level::Error, true>(__FILE__, __func__, __LINE__, \
+ (_msg))
/*
* BT_CPPLOGE_STR_APPEND_CAUSE_SPEC() using the default logger.
/*
* BT_CPPLOGE_STR_APPEND_CAUSE_SPEC() using the default logger.
* `_excCls`.
*/
#define BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(_logger, _excCls, _fmt, ...) \
* `_excCls`.
*/
#define BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(_logger, _excCls, _fmt, ...) \
- (_logger).logErrorAndThrow<true, _excCls>(__FILE__, __func__, __LINE__, (_fmt), ##__VA_ARGS__)
+ (_logger).template logErrorAndThrow<true, _excCls>(__FILE__, __func__, __LINE__, (_fmt), \
+ ##__VA_ARGS__)
/*
* BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC() using the default logger.
/*
* BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC() using the default logger.
* `_excCls`.
*/
#define BT_CPPLOGE_STR_APPEND_CAUSE_AND_THROW_SPEC(_logger, _excCls, _msg) \
* `_excCls`.
*/
#define BT_CPPLOGE_STR_APPEND_CAUSE_AND_THROW_SPEC(_logger, _excCls, _msg) \
- (_logger).logErrorStrAndThrow<true, _excCls>(__FILE__, __func__, __LINE__, (_msg))
+ (_logger).template logErrorStrAndThrow<true, _excCls>(__FILE__, __func__, __LINE__, (_msg))
/*
* BT_CPPLOGE_STR_APPEND_CAUSE_AND_THROW_SPEC() using the default
/*
* BT_CPPLOGE_STR_APPEND_CAUSE_AND_THROW_SPEC() using the default
* `_excCls`.
*/
#define BT_CPPLOGE_APPEND_CAUSE_AND_RETHROW_SPEC(_logger, _fmt, ...) \
* `_excCls`.
*/
#define BT_CPPLOGE_APPEND_CAUSE_AND_RETHROW_SPEC(_logger, _fmt, ...) \
- (_logger).logErrorAndRethrow<true>(__FILE__, __func__, __LINE__, (_fmt), ##__VA_ARGS__)
+ (_logger).template logErrorAndRethrow<true>(__FILE__, __func__, __LINE__, (_fmt), ##__VA_ARGS__)
/*
* BT_CPPLOGE_APPEND_CAUSE_AND_RETHROW_SPEC() using the default logger.
/*
* BT_CPPLOGE_APPEND_CAUSE_AND_RETHROW_SPEC() using the default logger.
* `_excCls`.
*/
#define BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW_SPEC(_logger, _msg) \
* `_excCls`.
*/
#define BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW_SPEC(_logger, _msg) \
- (_logger).logErrorStrAndRethrow<true>(__FILE__, __func__, __LINE__, (_msg))
+ (_logger).template logErrorStrAndRethrow<true>(__FILE__, __func__, __LINE__, (_msg))
/*
* BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW_SPEC() using the default
/*
* BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW_SPEC() using the default
* error and append a cause to the error of the current thread.
*/
#define BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC(_logger, _initMsg, _fmt, ...) \
* error and append a cause to the error of the current thread.
*/
#define BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC(_logger, _initMsg, _fmt, ...) \
- (_logger).logErrno<bt2c::Logger::Level::Error, true>(__FILE__, __func__, __LINE__, (_initMsg), \
- (_fmt), ##__VA_ARGS__)
+ (_logger).template logErrno<bt2c::Logger::Level::Error, true>( \
+ __FILE__, __func__, __LINE__, (_initMsg), (_fmt), ##__VA_ARGS__)
/*
* BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC() using the default logger.
/*
* BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC() using the default logger.
* an error and append a cause to the error of the current thread.
*/
#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_SPEC(_logger, _initMsg, _msg) \
* an error and append a cause to the error of the current thread.
*/
#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_SPEC(_logger, _initMsg, _msg) \
- (_logger).logErrnoStr<bt2c::Logger::Level::Error, true>(__FILE__, __func__, __LINE__, \
- (_initMsg), (_msg))
+ (_logger).template logErrnoStr<bt2c::Logger::Level::Error, true>(__FILE__, __func__, __LINE__, \
+ (_initMsg), (_msg))
/*
* BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_SPEC() using the default logger.
/*
* BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_SPEC() using the default logger.
* `_excCls`.
*/
#define BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_THROW_SPEC(_logger, _excCls, _initMsg, _fmt, ...) \
* `_excCls`.
*/
#define BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_THROW_SPEC(_logger, _excCls, _initMsg, _fmt, ...) \
- (_logger).logErrorErrnoAndThrow<true, _excCls>(__FILE__, __func__, __LINE__, (_initMsg), \
- (_fmt), ##__VA_ARGS__)
+ (_logger).template logErrorErrnoAndThrow<true, _excCls>(__FILE__, __func__, __LINE__, \
+ (_initMsg), (_fmt), ##__VA_ARGS__)
/*
* BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_THROW_SPEC() using the default
/*
* BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_THROW_SPEC() using the default
* `_excCls`.
*/
#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_THROW_SPEC(_logger, _excCls, _initMsg, _msg) \
* `_excCls`.
*/
#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_THROW_SPEC(_logger, _excCls, _initMsg, _msg) \
- (_logger).logErrorErrnoStrAndThrow<true, _excCls>(__FILE__, __func__, __LINE__, (_initMsg), \
- (_msg))
+ (_logger).template logErrorErrnoStrAndThrow<true, _excCls>(__FILE__, __func__, __LINE__, \
+ (_initMsg), (_msg))
/*
* BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_THROW_SPEC() using the default
/*
* BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_THROW_SPEC() using the default
* `_excCls`.
*/
#define BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_RETHROW_SPEC(_logger, _initMsg, _fmt, ...) \
* `_excCls`.
*/
#define BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_RETHROW_SPEC(_logger, _initMsg, _fmt, ...) \
- (_logger).logErrorErrnoAndRethrow<true>(__FILE__, __func__, __LINE__, (_initMsg), (_fmt), \
- ##__VA_ARGS__)
+ (_logger).template logErrorErrnoAndRethrow<true>(__FILE__, __func__, __LINE__, (_initMsg), \
+ (_fmt), ##__VA_ARGS__)
/*
* BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_RETHROW_SPEC() using the default
/*
* BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_RETHROW_SPEC() using the default
* instance of `_excCls`.
*/
#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_RETHROW_SPEC(_logger, _initMsg, _msg) \
* instance of `_excCls`.
*/
#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_RETHROW_SPEC(_logger, _initMsg, _msg) \
- (_logger).logErrorErrnoStrAndRethrow<true>(__FILE__, __func__, __LINE__, (_initMsg), (_msg))
+ (_logger).template logErrorErrnoStrAndRethrow<true>(__FILE__, __func__, __LINE__, (_initMsg), \
+ (_msg))
/*
* BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_RETHROW_SPEC() using the
/*
* BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_RETHROW_SPEC() using the