I think that the `noThrow` suffixes are unnecessary. Since the methods
that throw (or rethrow) have the `AndThrow` (or `AndRethrow`) suffixes,
it is implied that those that don't, don't.
Simplify some macro comments to omit "without appending nor throwing",
for the same reason (if the macro name doesn't contain "APPEND_CAUSE",
it doesn't append a cause, if it doesn't contain "THROW", it doesn't
throw).
Change-Id: Ia71cf733e857e89578648eda12bf64b2bfc65027
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12229
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
* self message iterator, or simple module name), a current logging
* level, and a logging tag.
*
* self message iterator, or simple module name), a current logging
* level, and a logging tag.
*
- * It offers the logNoThrow(), logMemNoThrow(), logErrnoNoThrow(),
- * logErrorAndThrow(), logErrorAndRethrow(), logErrorErrnoAndThrow(),
- * and logErrorErrnoAndRethrow() method templates to log using a given
+ * It offers the log(), logMem(), logErrno(), logErrorAndThrow(),
+ * logErrorAndRethrow(), logErrorErrnoAndThrow(), and
+ * logErrorErrnoAndRethrow() method templates to log using a given
* level, optionally append a cause to the error of the current thread
* using the correct actor, and optionally throw or rethrow.
*
* level, optionally append a cause to the error of the current thread
* using the correct actor, and optionally throw or rethrow.
*
* the error of the current thread using the same message.
*/
template <Level LevelV, bool AppendCauseV, typename... ArgTs>
* the error of the current thread using the same message.
*/
template <Level LevelV, bool AppendCauseV, typename... ArgTs>
- void logNoThrow(const char * const fileName, const char * const funcName,
- const unsigned int lineNo, const char * const fmt, ArgTs&&...args) const
+ void log(const char * const fileName, const char * const funcName, const unsigned int lineNo,
+ const char * const fmt, ArgTs&&...args) const
- this->_logNoThrow<_StdLogWriter, LevelV, AppendCauseV>(
- fileName, funcName, lineNo, nullptr, 0, "", fmt, std::forward<ArgTs>(args)...);
+ this->_log<_StdLogWriter, LevelV, AppendCauseV>(fileName, funcName, lineNo, nullptr, 0, "",
+ fmt, std::forward<ArgTs>(args)...);
* the error of the current thread using the same message.
*/
template <Level LevelV, bool AppendCauseV>
* the error of the current thread using the same message.
*/
template <Level LevelV, bool AppendCauseV>
- void logStrNoThrow(const char * const fileName, const char * const funcName,
- const unsigned int lineNo, const char * const msg) const
+ void logStr(const char * const fileName, const char * const funcName, const unsigned int lineNo,
+ const char * const msg) const
- this->_logStrNoThrow<_StdLogWriter, LevelV, AppendCauseV>(fileName, funcName, lineNo,
- nullptr, 0, "", msg);
+ this->_logStr<_StdLogWriter, LevelV, AppendCauseV>(fileName, funcName, lineNo, nullptr, 0,
+ "", msg);
- * Like logNoThrow() with the `Level::Error` level, but also
- * throws a default-constructed instance of `ExcT`.
+ * Like log() with the `Level::Error` level, but also throws a
+ * default-constructed instance of `ExcT`.
*/
template <bool AppendCauseV, typename ExcT, typename... ArgTs>
[[noreturn]] void logErrorAndThrow(const char * const fileName, const char * const funcName,
const unsigned int lineNo, const char * const fmt,
ArgTs&&...args) const
{
*/
template <bool AppendCauseV, typename ExcT, typename... ArgTs>
[[noreturn]] void logErrorAndThrow(const char * const fileName, const char * const funcName,
const unsigned int lineNo, const char * const fmt,
ArgTs&&...args) const
{
- this->logNoThrow<Level::Error, AppendCauseV>(fileName, funcName, lineNo, fmt,
- std::forward<ArgTs>(args)...);
+ this->log<Level::Error, AppendCauseV>(fileName, funcName, lineNo, fmt,
+ std::forward<ArgTs>(args)...);
- * Like logStrNoThrow() with the `Level::Error` level, but also
- * throws a default-constructed instance of `ExcT`.
+ * Like logStr() with the `Level::Error` level, but also throws a
+ * default-constructed instance of `ExcT`.
*/
template <bool AppendCauseV, typename ExcT>
[[noreturn]] void logErrorStrAndThrow(const char * const fileName, const char * const funcName,
const unsigned int lineNo, const char * const msg) const
{
*/
template <bool AppendCauseV, typename ExcT>
[[noreturn]] void logErrorStrAndThrow(const char * const fileName, const char * const funcName,
const unsigned int lineNo, const char * const msg) const
{
- this->logStrNoThrow<Level::Error, AppendCauseV>(fileName, funcName, lineNo, msg);
+ this->logStr<Level::Error, AppendCauseV>(fileName, funcName, lineNo, msg);
- * Like logNoThrow() with the `Level::Error` level, but also
- * rethrows.
+ * Like log() with the `Level::Error` level, but also rethrows.
*/
template <bool AppendCauseV, typename... ArgTs>
[[noreturn]] void logErrorAndRethrow(const char * const fileName, const char * const funcName,
const unsigned int lineNo, const char * const fmt,
ArgTs&&...args) const
{
*/
template <bool AppendCauseV, typename... ArgTs>
[[noreturn]] void logErrorAndRethrow(const char * const fileName, const char * const funcName,
const unsigned int lineNo, const char * const fmt,
ArgTs&&...args) const
{
- this->logNoThrow<Level::Error, AppendCauseV>(fileName, funcName, lineNo, fmt,
- std::forward<ArgTs>(args)...);
+ this->log<Level::Error, AppendCauseV>(fileName, funcName, lineNo, fmt,
+ std::forward<ArgTs>(args)...);
- * Like logStrNoThrow() with the `Level::Error` level, but also
- * rethrows.
+ * Like logStr() with the `Level::Error` level, but also rethrows.
*/
template <bool AppendCauseV>
[[noreturn]] void logErrorStrAndRethrow(const char * const fileName,
const char * const funcName, const unsigned int lineNo,
const char * const msg) const
{
*/
template <bool AppendCauseV>
[[noreturn]] void logErrorStrAndRethrow(const char * const fileName,
const char * const funcName, const unsigned int lineNo,
const char * const msg) const
{
- this->logStrNoThrow<Level::Error, AppendCauseV>(fileName, funcName, lineNo, msg);
+ this->logStr<Level::Error, AppendCauseV>(fileName, funcName, lineNo, msg);
* the error of the current thread using the same message.
*/
template <Level LevelV, bool AppendCauseV, typename... ArgTs>
* the error of the current thread using the same message.
*/
template <Level LevelV, bool AppendCauseV, typename... ArgTs>
- void logErrnoNoThrow(const char * const fileName, const char * const funcName,
- const unsigned int lineNo, const char * const initMsg,
- const char * const fmt, ArgTs&&...args) const
+ void logErrno(const char * const fileName, const char * const funcName,
+ const unsigned int lineNo, const char * const initMsg, const char * const fmt,
+ ArgTs&&...args) const
- this->_logNoThrow<_InitMsgLogWriter, LevelV, AppendCauseV>(
- fileName, funcName, lineNo, nullptr, 0, this->_errnoIntroStr(initMsg).c_str(), fmt,
- std::forward<ArgTs>(args)...);
+ this->_log<_InitMsgLogWriter, LevelV, AppendCauseV>(fileName, funcName, lineNo, nullptr, 0,
+ this->_errnoIntroStr(initMsg).c_str(),
+ fmt, std::forward<ArgTs>(args)...);
* the error of the current thread using the same message.
*/
template <Level LevelV, bool AppendCauseV>
* the error of the current thread using the same message.
*/
template <Level LevelV, bool AppendCauseV>
- void logErrnoStrNoThrow(const char * const fileName, const char * const funcName,
- const unsigned int lineNo, const char * const initMsg,
- const char * const msg) const
+ void logErrnoStr(const char * const fileName, const char * const funcName,
+ const unsigned int lineNo, const char * const initMsg,
+ const char * const msg) const
- this->_logStrNoThrow<_InitMsgLogWriter, LevelV, AppendCauseV>(
+ this->_logStr<_InitMsgLogWriter, LevelV, AppendCauseV>(
fileName, funcName, lineNo, nullptr, 0, this->_errnoIntroStr(initMsg).c_str(), msg);
}
/*
fileName, funcName, lineNo, nullptr, 0, this->_errnoIntroStr(initMsg).c_str(), msg);
}
/*
- * Like logErrnoNoThrow() with the `Level::Error` level, but also
- * throws a default-constructed instance of `ExcT`.
+ * Like logErrno() with the `Level::Error` level, but also throws a
+ * default-constructed instance of `ExcT`.
*/
template <bool AppendCauseV, typename ExcT, typename... ArgTs>
[[noreturn]] void logErrorErrnoAndThrow(const char * const fileName,
*/
template <bool AppendCauseV, typename ExcT, typename... ArgTs>
[[noreturn]] void logErrorErrnoAndThrow(const char * const fileName,
const char * const initMsg, const char * const fmt,
ArgTs&&...args) const
{
const char * const initMsg, const char * const fmt,
ArgTs&&...args) const
{
- this->logErrnoNoThrow<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg, fmt,
- std::forward<ArgTs>(args)...);
+ this->logErrno<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg, fmt,
+ std::forward<ArgTs>(args)...);
- * Like logErrnoStrNoThrow() with the `Level::Error` level, but also
- * throws a default-constructed instance of `ExcT`.
+ * Like logErrnoStr() with the `Level::Error` level, but also throws
+ * a default-constructed instance of `ExcT`.
*/
template <bool AppendCauseV, typename ExcT>
[[noreturn]] void
*/
template <bool AppendCauseV, typename ExcT>
[[noreturn]] void
const unsigned int lineNo, const char * const initMsg,
const char * const msg) const
{
const unsigned int lineNo, const char * const initMsg,
const char * const msg) const
{
- this->logErrnoStrNoThrow<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg,
- msg);
+ this->logErrnoStr<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg, msg);
- * Like logErrnoNoThrow() with the `Level::Error` level, but also
- * rethrows.
+ * Like logErrno() with the `Level::Error` level, but also rethrows.
*/
template <bool AppendCauseV, typename... ArgTs>
[[noreturn]] void logErrorErrnoAndRethrow(const char * const fileName,
*/
template <bool AppendCauseV, typename... ArgTs>
[[noreturn]] void logErrorErrnoAndRethrow(const char * const fileName,
const unsigned int lineNo, const char * const initMsg,
const char * const fmt, ArgTs&&...args) const
{
const unsigned int lineNo, const char * const initMsg,
const char * const fmt, ArgTs&&...args) const
{
- this->logErrnoNoThrow<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg, fmt,
- std::forward<ArgTs>(args)...);
+ this->logErrno<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg, fmt,
+ std::forward<ArgTs>(args)...);
- * Like logErrnoStrNoThrow() with the `Level::Error` level, but also
+ * Like logErrnoStr() with the `Level::Error` level, but also
* rethrows.
*/
template <bool AppendCauseV>
* rethrows.
*/
template <bool AppendCauseV>
const unsigned int lineNo, const char * const initMsg,
const char * const msg) const
{
const unsigned int lineNo, const char * const initMsg,
const char * const msg) const
{
- this->logErrnoStrNoThrow<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg,
- msg);
+ this->logErrnoStr<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg, msg);
* the log message.
*/
template <Level LevelV, typename... ArgTs>
* the log message.
*/
template <Level LevelV, typename... ArgTs>
- void logMemNoThrow(const char * const fileName, const char * const funcName,
- const unsigned int lineNo, const void * const memData,
- const unsigned int memLen, const char * const fmt, ArgTs&&...args) const
+ void logMem(const char * const fileName, const char * const funcName, const unsigned int lineNo,
+ const void * const memData, const unsigned int memLen, const char * const fmt,
+ ArgTs&&...args) const
- this->_logNoThrow<_MemLogWriter, LevelV, false>(fileName, funcName, lineNo, memData, memLen,
- "", fmt, std::forward<ArgTs>(args)...);
+ this->_log<_MemLogWriter, LevelV, false>(fileName, funcName, lineNo, memData, memLen, "",
+ fmt, std::forward<ArgTs>(args)...);
* message `msg`.
*/
template <Level LevelV>
* message `msg`.
*/
template <Level LevelV>
- void logMemStrNoThrow(const char * const fileName, const char * const funcName,
- const unsigned int lineNo, const void * const memData,
- const unsigned int memLen, const char * const msg) const
+ void logMemStr(const char * const fileName, const char * const funcName,
+ const unsigned int lineNo, const void * const memData, const unsigned int memLen,
+ const char * const msg) const
- this->_logStrNoThrow<_MemLogWriter, LevelV, false>(fileName, funcName, lineNo, memData,
- memLen, "", msg);
+ this->_logStr<_MemLogWriter, LevelV, false>(fileName, funcName, lineNo, memData, memLen, "",
+ msg);
}
private:
/*
* Formats a log message with fmt::format() given `fmt` and `args`,
}
private:
/*
* Formats a log message with fmt::format() given `fmt` and `args`,
- * and then forwards everything to _logStrNoThrow().
+ * and then forwards everything to _logStr().
*/
template <typename LogWriterT, Level LevelV, bool AppendCauseV, typename... ArgTs>
*/
template <typename LogWriterT, Level LevelV, bool AppendCauseV, typename... ArgTs>
- void _logNoThrow(const char * const fileName, const char * const funcName,
- const unsigned int lineNo, const void * const memData,
- const std::size_t memLen, const char * const initMsg, const char * const fmt,
- ArgTs&&...args) const
+ void _log(const char * const fileName, const char * const funcName, const unsigned int lineNo,
+ const void * const memData, const std::size_t memLen, const char * const initMsg,
+ const char * const fmt, ArgTs&&...args) const
{
/* Only format arguments if logging or appending an error cause */
if (G_UNLIKELY(this->wouldLog(LevelV) || AppendCauseV)) {
{
/* Only format arguments if logging or appending an error cause */
if (G_UNLIKELY(this->wouldLog(LevelV) || AppendCauseV)) {
- this->_logStrNoThrow<LogWriterT, LevelV, AppendCauseV>(fileName, funcName, lineNo, memData,
- memLen, initMsg, _mBuf.data());
+ this->_logStr<LogWriterT, LevelV, AppendCauseV>(fileName, funcName, lineNo, memData, memLen,
+ initMsg, _mBuf.data());
* `initMsg` and `msg` as the message.
*/
template <typename LogWriterT, Level LevelV, bool AppendCauseV>
* `initMsg` and `msg` as the message.
*/
template <typename LogWriterT, Level LevelV, bool AppendCauseV>
- void _logStrNoThrow(const char * const fileName, const char * const funcName,
- const unsigned int lineNo, const void * const memData,
- const std::size_t memLen, const char * const initMsg,
- const char * const msg) const
+ void _logStr(const char * const fileName, const char * const funcName,
+ const unsigned int lineNo, const void * const memData, const std::size_t memLen,
+ const char * const initMsg, const char * const msg) const
{
/* Initial message and main message are required */
BT_ASSERT(initMsg);
{
/* Initial message and main message are required */
BT_ASSERT(initMsg);
#define _BT_CPPLOG_DEF_LOGGER _mLogger
/*
#define _BT_CPPLOG_DEF_LOGGER _mLogger
/*
- * Calls logNoThrow() on `_logger` to log using the level `_lvl` without
- * appending nor throwing.
+ * Calls log() on `_logger` to log using the level `_lvl`.
*/
#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).logNoThrow<(_lvl), false>(__FILE__, __func__, __LINE__, (_fmt), \
- ##__VA_ARGS__); \
+ (_logger).log<(_lvl), false>(__FILE__, __func__, __LINE__, (_fmt), ##__VA_ARGS__); \
#define BT_CPPLOGF(_fmt, ...) BT_CPPLOGF_SPEC(_BT_CPPLOG_DEF_LOGGER, (_fmt), ##__VA_ARGS__)
/*
#define BT_CPPLOGF(_fmt, ...) BT_CPPLOGF_SPEC(_BT_CPPLOG_DEF_LOGGER, (_fmt), ##__VA_ARGS__)
/*
- * Calls logStrNoThrow() on `_logger` to log using the level `_lvl`
- * without appending nor throwing.
+ * Calls logStr() on `_logger` to log using the level `_lvl`.
*/
#define BT_CPPLOG_STR_EX(_lvl, _logger, _msg) \
*/
#define BT_CPPLOG_STR_EX(_lvl, _logger, _msg) \
- (_logger).logStrNoThrow<(_lvl), false>(__FILE__, __func__, __LINE__, (_msg))
+ (_logger).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_CPPLOGF_STR(_msg) BT_CPPLOGF_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg))
/*
#define BT_CPPLOGF_STR(_msg) BT_CPPLOGF_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg))
/*
- * Calls logMemNoThrow() on `_logger` to log using the level `_lvl`
- * without appending nor throwing.
+ * Calls logMem() on `_logger` to log using the level `_lvl`.
*/
#define BT_CPPLOG_MEM_EX(_lvl, _logger, _mem_data, _mem_len, _fmt, ...) \
do { \
if (G_UNLIKELY((_logger).wouldLog(_lvl))) { \
*/
#define BT_CPPLOG_MEM_EX(_lvl, _logger, _mem_data, _mem_len, _fmt, ...) \
do { \
if (G_UNLIKELY((_logger).wouldLog(_lvl))) { \
- (_logger).logMemNoThrow<(_lvl)>(__FILE__, __func__, __LINE__, (_mem_data), (_mem_len), \
- (_fmt), ##__VA_ARGS__); \
+ (_logger).logMem<(_lvl)>(__FILE__, __func__, __LINE__, (_mem_data), (_mem_len), \
+ (_fmt), ##__VA_ARGS__); \
BT_CPPLOGF_MEM_SPEC(_BT_CPPLOG_DEF_LOGGER, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
/*
BT_CPPLOGF_MEM_SPEC(_BT_CPPLOG_DEF_LOGGER, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
/*
- * Calls logMemStrNoThrow() on `_logger` to log using the level `_lvl`
- * without appending nor throwing.
+ * Calls logMemStr() on `_logger` to log using the level `_lvl`.
*/
#define BT_CPPLOG_MEM_STR_EX(_lvl, _logger, _mem_data, _mem_len, _msg) \
*/
#define BT_CPPLOG_MEM_STR_EX(_lvl, _logger, _mem_data, _mem_len, _msg) \
- (_logger).logMemStrNoThrow<(_lvl)>(__FILE__, __func__, __LINE__, (_mem_data), (_mem_len), \
- (_msg))
+ (_logger).logMemStr<(_lvl)>(__FILE__, __func__, __LINE__, (_mem_data), (_mem_len), (_msg))
/*
* BT_CPPLOG_MEM_STR_EX() with specific logging levels.
/*
* BT_CPPLOG_MEM_STR_EX() with specific logging levels.
BT_CPPLOGF_MEM_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_mem_data), (_mem_len), (_msg))
/*
BT_CPPLOGF_MEM_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_mem_data), (_mem_len), (_msg))
/*
- * Calls logErrnoNoThrow() on `_logger` to log using the level `_lvl`
- * and initial message `_init_msg` without appending nor throwing.
+ * Calls logErrno() on `_logger` to log using the level `_lvl` and
+ * initial message `_init_msg`.
*/
#define BT_CPPLOG_ERRNO_EX(_lvl, _logger, _init_msg, _fmt, ...) \
do { \
if (G_UNLIKELY((_logger).wouldLog(_lvl))) { \
*/
#define BT_CPPLOG_ERRNO_EX(_lvl, _logger, _init_msg, _fmt, ...) \
do { \
if (G_UNLIKELY((_logger).wouldLog(_lvl))) { \
- (_logger).logErrnoNoThrow<(_lvl), false>(__FILE__, __func__, __LINE__, (_init_msg), \
- (_fmt), ##__VA_ARGS__); \
+ (_logger).logErrno<(_lvl), false>(__FILE__, __func__, __LINE__, (_init_msg), (_fmt), \
+ ##__VA_ARGS__); \
BT_CPPLOGF_ERRNO_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_fmt), ##__VA_ARGS__)
/*
BT_CPPLOGF_ERRNO_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_fmt), ##__VA_ARGS__)
/*
- * Calls logErrnoStrNoThrow() on `_logger` to log using the level `_lvl`
- * and initial message `_init_msg` without appending nor throwing.
+ * Calls logErrnoStr() on `_logger` to log using the level `_lvl` and
+ * initial message `_init_msg`.
*/
#define BT_CPPLOG_ERRNO_STR_EX(_lvl, _logger, _init_msg, _msg) \
*/
#define BT_CPPLOG_ERRNO_STR_EX(_lvl, _logger, _init_msg, _msg) \
- (_logger).logErrnoStrNoThrow<(_lvl), false>(__FILE__, __func__, __LINE__, (_init_msg), (_msg))
+ (_logger).logErrnoStr<(_lvl), false>(__FILE__, __func__, __LINE__, (_init_msg), (_msg))
/*
* BT_CPPLOG_ERRNO_STR_EX() with specific logging levels.
/*
* BT_CPPLOG_ERRNO_STR_EX() with specific logging levels.