* 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.
*
/* Available log levels */
enum class Level
{
- TRACE = BT_LOG_TRACE,
- DEBUG = BT_LOG_DEBUG,
- INFO = BT_LOG_INFO,
- WARNING = BT_LOG_WARNING,
- ERROR = BT_LOG_ERROR,
- FATAL = BT_LOG_FATAL,
- NONE = BT_LOG_NONE,
+ Trace = BT_LOG_TRACE,
+ Debug = BT_LOG_DEBUG,
+ Info = BT_LOG_INFO,
+ Warning = BT_LOG_WARNING,
+ Error = BT_LOG_ERROR,
+ Fatal = BT_LOG_FATAL,
+ None = BT_LOG_NONE,
};
/*
* using the tag `tag`.
*/
explicit Logger(const bt2::SelfMessageIterator selfMsgIter, std::string tag) noexcept :
- Logger {selfMsgIter.component(), std::move(tag)}
+ _mSelfMsgIter {selfMsgIter},
+ _mLevel {static_cast<Level>(selfMsgIter.component().loggingLevel())}, _mTag {std::move(tag)}
{
- _mSelfMsgIter = selfMsgIter;
}
/*
* `newTag`.
*/
explicit Logger(const Logger& other, std::string newTag) :
- _mSelfComp {other._mSelfComp}, _mSelfMsgIter {other._mSelfMsgIter},
+ _mSelfCompCls {other._mSelfCompCls}, _mSelfComp {other._mSelfComp},
+ _mSelfMsgIter {other._mSelfMsgIter},
_mModuleName {other._mModuleName}, _mLevel {other._mLevel}, _mTag {std::move(newTag)}
{
}
*/
bool wouldLogT() const noexcept
{
- return this->wouldLog(Level::TRACE);
+ return this->wouldLog(Level::Trace);
}
/*
*/
bool wouldLogD() const noexcept
{
- return this->wouldLog(Level::DEBUG);
+ return this->wouldLog(Level::Debug);
}
/*
*/
bool wouldLogI() const noexcept
{
- return this->wouldLog(Level::INFO);
+ return this->wouldLog(Level::Info);
}
/*
*/
bool wouldLogW() const noexcept
{
- return this->wouldLog(Level::WARNING);
+ return this->wouldLog(Level::Warning);
}
/*
*/
bool wouldLogE() const noexcept
{
- return this->wouldLog(Level::ERROR);
+ return this->wouldLog(Level::Error);
}
/*
*/
bool wouldLogF() const noexcept
{
- return this->wouldLog(Level::FATAL);
+ return this->wouldLog(Level::Fatal);
}
/*
* 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>
- 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 logAndNoThrow() 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
{
- 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)...);
throw ExcT {};
}
/*
- * Like logStrAndNoThrow() 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
{
- this->logStrNoThrow<Level::ERROR, AppendCauseV>(fileName, funcName, lineNo, msg);
+ this->logStr<Level::Error, AppendCauseV>(fileName, funcName, lineNo, msg);
throw ExcT {};
}
/*
- * Like logAndNoThrow() 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
{
- 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)...);
throw;
}
/*
- * Like logStrAndNoThrow() 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
{
- this->logStrNoThrow<Level::ERROR, AppendCauseV>(fileName, funcName, lineNo, msg);
+ this->logStr<Level::Error, AppendCauseV>(fileName, funcName, lineNo, msg);
throw;
}
* 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>
- 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);
}
/*
- * 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,
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)...);
throw ExcT {};
}
/*
- * 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
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);
throw ExcT {};
}
/*
- * 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,
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)...);
throw;
}
/*
- * Like logErrnoStrNoThrow() with the `Level::ERROR` level, but also
+ * Like logErrnoStr() with the `Level::Error` level, but also
* rethrows.
*/
template <bool AppendCauseV>
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);
throw;
}
* 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>
- 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`,
- * and then forwards everything to _logStrNoThrow().
+ * and then forwards everything to _logStr().
*/
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)) {
_mBuf.push_back('\0');
}
- 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>
- 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);
if (AppendCauseV) {
if (_mSelfMsgIter) {
bt_current_thread_error_append_cause_from_message_iterator(
- _mSelfMsgIter->libObjPtr(), fileName, lineNo, "%s%s", initMsg, _mBuf.data());
+ _mSelfMsgIter->libObjPtr(), fileName, lineNo, "%s%s", initMsg, msg);
} else if (_mSelfComp) {
bt_current_thread_error_append_cause_from_component(
- _mSelfComp->libObjPtr(), fileName, lineNo, "%s%s", initMsg, _mBuf.data());
+ _mSelfComp->libObjPtr(), fileName, lineNo, "%s%s", initMsg, msg);
} else if (_mSelfCompCls) {
bt_current_thread_error_append_cause_from_component_class(
- _mSelfCompCls->libObjPtr(), fileName, lineNo, "%s%s", initMsg, _mBuf.data());
+ _mSelfCompCls->libObjPtr(), fileName, lineNo, "%s%s", initMsg, msg);
} else {
BT_ASSERT(_mModuleName);
- bt_current_thread_error_append_cause_from_unknown(
- _mModuleName->data(), fileName, lineNo, "%s%s", initMsg, _mBuf.data());
+ bt_current_thread_error_append_cause_from_unknown(_mModuleName->data(), fileName,
+ lineNo, "%s%s", initMsg, msg);
}
}
}
return fmt::format("{}: {}", initMsg, g_strerror(errno));
}
- /* At least one of the following four members has a value */
+ /* Exactly one of the following four members has a value */
bt2s::optional<bt2::SelfComponentClass> _mSelfCompCls;
bt2s::optional<bt2::SelfComponent> _mSelfComp;
bt2s::optional<bt2::SelfMessageIterator> _mSelfMsgIter;
#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))) { \
- (_logger).logNoThrow<(_lvl), false>(__FILE__, __func__, __LINE__, (_fmt), \
- ##__VA_ARGS__); \
+ (_logger).log<(_lvl), false>(__FILE__, __func__, __LINE__, (_fmt), ##__VA_ARGS__); \
} \
} while (0)
* BT_CPPLOG_EX() with specific logging levels.
*/
#define BT_CPPLOGT_SPEC(_logger, _fmt, ...) \
- BT_CPPLOG_EX(bt2c::Logger::Level::TRACE, (_logger), (_fmt), ##__VA_ARGS__)
+ BT_CPPLOG_EX(bt2c::Logger::Level::Trace, (_logger), (_fmt), ##__VA_ARGS__)
#define BT_CPPLOGD_SPEC(_logger, _fmt, ...) \
- BT_CPPLOG_EX(bt2c::Logger::Level::DEBUG, (_logger), (_fmt), ##__VA_ARGS__)
+ BT_CPPLOG_EX(bt2c::Logger::Level::Debug, (_logger), (_fmt), ##__VA_ARGS__)
#define BT_CPPLOGI_SPEC(_logger, _fmt, ...) \
- BT_CPPLOG_EX(bt2c::Logger::Level::INFO, (_logger), (_fmt), ##__VA_ARGS__)
+ BT_CPPLOG_EX(bt2c::Logger::Level::Info, (_logger), (_fmt), ##__VA_ARGS__)
#define BT_CPPLOGW_SPEC(_logger, _fmt, ...) \
- BT_CPPLOG_EX(bt2c::Logger::Level::WARNING, (_logger), (_fmt), ##__VA_ARGS__)
+ BT_CPPLOG_EX(bt2c::Logger::Level::Warning, (_logger), (_fmt), ##__VA_ARGS__)
#define BT_CPPLOGE_SPEC(_logger, _fmt, ...) \
- BT_CPPLOG_EX(bt2c::Logger::Level::ERROR, (_logger), (_fmt), ##__VA_ARGS__)
+ BT_CPPLOG_EX(bt2c::Logger::Level::Error, (_logger), (_fmt), ##__VA_ARGS__)
#define BT_CPPLOGF_SPEC(_logger, _fmt, ...) \
- BT_CPPLOG_EX(bt2c::Logger::Level::FATAL, (_logger), (_fmt), ##__VA_ARGS__)
+ BT_CPPLOG_EX(bt2c::Logger::Level::Fatal, (_logger), (_fmt), ##__VA_ARGS__)
/*
* BT_CPPLOG_EX() with specific logging levels and using the default
#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) \
- (_logger).logStrNoThrow<(_lvl), false>(__FILE__, __func__, __LINE__, (_msg))
+ (_logger).logStr<(_lvl), false>(__FILE__, __func__, __LINE__, (_msg))
/*
* BT_CPPLOG_STR_EX() with specific logging levels.
*/
#define BT_CPPLOGT_STR_SPEC(_logger, _msg) \
- BT_CPPLOG_STR_EX(bt2c::Logger::Level::TRACE, (_logger), (_msg))
+ BT_CPPLOG_STR_EX(bt2c::Logger::Level::Trace, (_logger), (_msg))
#define BT_CPPLOGD_STR_SPEC(_logger, _msg) \
- BT_CPPLOG_STR_EX(bt2c::Logger::Level::DEBUG, (_logger), (_msg))
+ BT_CPPLOG_STR_EX(bt2c::Logger::Level::Debug, (_logger), (_msg))
#define BT_CPPLOGI_STR_SPEC(_logger, _msg) \
- BT_CPPLOG_STR_EX(bt2c::Logger::Level::INFO, (_logger), (_msg))
+ BT_CPPLOG_STR_EX(bt2c::Logger::Level::Info, (_logger), (_msg))
#define BT_CPPLOGW_STR_SPEC(_logger, _msg) \
- BT_CPPLOG_STR_EX(bt2c::Logger::Level::WARNING, (_logger), (_msg))
+ BT_CPPLOG_STR_EX(bt2c::Logger::Level::Warning, (_logger), (_msg))
#define BT_CPPLOGE_STR_SPEC(_logger, _msg) \
- BT_CPPLOG_STR_EX(bt2c::Logger::Level::ERROR, (_logger), (_msg))
+ BT_CPPLOG_STR_EX(bt2c::Logger::Level::Error, (_logger), (_msg))
#define BT_CPPLOGF_STR_SPEC(_logger, _msg) \
- BT_CPPLOG_STR_EX(bt2c::Logger::Level::FATAL, (_logger), (_msg))
+ BT_CPPLOG_STR_EX(bt2c::Logger::Level::Fatal, (_logger), (_msg))
/*
* BT_CPPLOG_STR_EX() with specific logging levels and using the default
#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))) { \
- (_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__); \
} \
} while (0)
* BT_CPPLOG_MEM_EX() with specific logging levels.
*/
#define BT_CPPLOGT_MEM_SPEC(_logger, _mem_data, _mem_len, _fmt, ...) \
- BT_CPPLOG_MEM_EX(bt2c::Logger::Level::TRACE, (_logger), (_mem_data), (_mem_len), (_fmt), \
+ BT_CPPLOG_MEM_EX(bt2c::Logger::Level::Trace, (_logger), (_mem_data), (_mem_len), (_fmt), \
##__VA_ARGS__)
#define BT_CPPLOGD_MEM_SPEC(_logger, _mem_data, _mem_len, _fmt, ...) \
- BT_CPPLOG_MEM_EX(bt2c::Logger::Level::DEBUG, (_logger), (_mem_data), (_mem_len), (_fmt), \
+ BT_CPPLOG_MEM_EX(bt2c::Logger::Level::Debug, (_logger), (_mem_data), (_mem_len), (_fmt), \
##__VA_ARGS__)
#define BT_CPPLOGI_MEM_SPEC(_logger, _mem_data, _mem_len, _fmt, ...) \
- BT_CPPLOG_MEM_EX(bt2c::Logger::Level::INFO, (_logger), (_mem_data), (_mem_len), (_fmt), \
+ BT_CPPLOG_MEM_EX(bt2c::Logger::Level::Info, (_logger), (_mem_data), (_mem_len), (_fmt), \
##__VA_ARGS__)
#define BT_CPPLOGW_MEM_SPEC(_logger, _mem_data, _mem_len, _fmt, ...) \
- BT_CPPLOG_MEM_EX(bt2c::Logger::Level::WARNING, (_logger), (_mem_data), (_mem_len), (_fmt), \
+ BT_CPPLOG_MEM_EX(bt2c::Logger::Level::Warning, (_logger), (_mem_data), (_mem_len), (_fmt), \
##__VA_ARGS__)
#define BT_CPPLOGE_MEM_SPEC(_logger, _mem_data, _mem_len, _fmt, ...) \
- BT_CPPLOG_MEM_EX(bt2c::Logger::Level::ERROR, (_logger), (_mem_data), (_mem_len), (_fmt), \
+ BT_CPPLOG_MEM_EX(bt2c::Logger::Level::Error, (_logger), (_mem_data), (_mem_len), (_fmt), \
##__VA_ARGS__)
#define BT_CPPLOGF_MEM_SPEC(_logger, _mem_data, _mem_len, _fmt, ...) \
- BT_CPPLOG_MEM_EX(bt2c::Logger::Level::FATAL, (_logger), (_mem_data), (_mem_len), (_fmt), \
+ BT_CPPLOG_MEM_EX(bt2c::Logger::Level::Fatal, (_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) \
- (_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.
#define BT_CPPLOGW_MEM_STR_SPEC(_logger, _mem_data, _mem_len, _msg) \
BT_CPPLOG_MEM_STR_EX(bt2c::Logger::Level::WARNING, (_logger), (_mem_data), (_mem_len), (_msg))
#define BT_CPPLOGE_MEM_STR_SPEC(_logger, _mem_data, _mem_len, _msg) \
- BT_CPPLOG_MEM_STR_EX(bt2c::Logger::Level::ERROR, (_logger), (_mem_data), (_mem_len), (_msg))
+ BT_CPPLOG_MEM_STR_EX(bt2c::Logger::Level::Error, (_logger), (_mem_data), (_mem_len), (_msg))
#define BT_CPPLOGF_MEM_STR_SPEC(_logger, _mem_data, _mem_len, _msg) \
BT_CPPLOG_MEM_STR_EX(bt2c::Logger::Level::FATAL, (_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))) { \
- (_logger).logErrnoNoThrow<(_lvl), false>(__FILE__, __func__, __LINE__, (_init_msg), \
- (_fmt), ##__VA_ARGS__); \
+ (_logger).logErrno<(_lvl), false>(__FILE__, __func__, __LINE__, (_init_msg), (_fmt), \
+ ##__VA_ARGS__); \
} \
} while (0)
* BT_CPPLOG_ERRNO_EX() with specific logging levels.
*/
#define BT_CPPLOGT_ERRNO_SPEC(_logger, _init_msg, _fmt, ...) \
- BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::TRACE, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
+ BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::Trace, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
#define BT_CPPLOGD_ERRNO_SPEC(_logger, _init_msg, _fmt, ...) \
- BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::DEBUG, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
+ BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::Debug, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
#define BT_CPPLOGI_ERRNO_SPEC(_logger, _init_msg, _fmt, ...) \
- BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::INFO, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
+ BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::Info, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
#define BT_CPPLOGW_ERRNO_SPEC(_logger, _init_msg, _fmt, ...) \
- BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::WARNING, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
+ BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::Warning, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
#define BT_CPPLOGE_ERRNO_SPEC(_logger, _init_msg, _fmt, ...) \
- BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::ERROR, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
+ BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::Error, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
#define BT_CPPLOGF_ERRNO_SPEC(_logger, _init_msg, _fmt, ...) \
- BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::FATAL, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
+ BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::Fatal, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
/*
* BT_CPPLOG_ERRNO_EX() with specific logging levels and using the
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) \
- (_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.
*/
#define BT_CPPLOGT_ERRNO_STR_SPEC(_logger, _init_msg, _msg) \
- BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::TRACE, (_logger), (_init_msg), (_msg))
+ BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Trace, (_logger), (_init_msg), (_msg))
#define BT_CPPLOGD_ERRNO_STR_SPEC(_logger, _init_msg, _msg) \
- BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::DEBUG, (_logger), (_init_msg), (_msg))
+ BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Debug, (_logger), (_init_msg), (_msg))
#define BT_CPPLOGI_ERRNO_STR_SPEC(_logger, _init_msg, _msg) \
- BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::INFO, (_logger), (_init_msg), (_msg))
+ BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Info, (_logger), (_init_msg), (_msg))
#define BT_CPPLOGW_ERRNO_STR_SPEC(_logger, _init_msg, _msg) \
- BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::WARNING, (_logger), (_init_msg), (_msg))
+ BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Warning, (_logger), (_init_msg), (_msg))
#define BT_CPPLOGE_ERRNO_STR_SPEC(_logger, _init_msg, _msg) \
- BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::ERROR, (_logger), (_init_msg), (_msg))
+ BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Error, (_logger), (_init_msg), (_msg))
#define BT_CPPLOGF_ERRNO_STR_SPEC(_logger, _init_msg, _msg) \
- BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::FATAL, (_logger), (_init_msg), (_msg))
+ BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Fatal, (_logger), (_init_msg), (_msg))
/*
* BT_CPPLOG_ERRNO_STR_EX() with specific logging levels and using the
BT_CPPLOGF_ERRNO_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_msg))
/*
- * Calls logErrorAndThrow() on `_logger` to log an error, append a cause
- * to the error of the current thread, and throw an instance of
- * `_exc_cls`.
+ * Calls log() on `_logger` with the `Error` level to log an error and
+ * append a cause to the error of the current thread.
*/
-#define BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(_logger, _exc_cls, _fmt, ...) \
- (_logger).logErrorAndThrow<true, _exc_cls>(__FILE__, __func__, __LINE__, (_fmt), ##__VA_ARGS__)
+#define BT_CPPLOGE_APPEND_CAUSE_SPEC(_logger, _fmt, ...) \
+ (_logger).log<bt2c::Logger::Level::Error, true>(__FILE__, __func__, __LINE__, (_fmt), \
+ ##__VA_ARGS__)
+
+/*
+ * BT_CPPLOGE_APPEND_CAUSE_SPEC() using the default logger.
+ */
+#define BT_CPPLOGE_APPEND_CAUSE(_fmt, ...) \
+ BT_CPPLOGE_APPEND_CAUSE_SPEC(_BT_CPPLOG_DEF_LOGGER, (_fmt), ##__VA_ARGS__)
+
+/*
+ * Calls logStr() on `_logger` with the `Error` level to log an error and
+ * 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))
+
+/*
+ * BT_CPPLOGE_STR_APPEND_CAUSE_SPEC() using the default logger.
+ */
+#define BT_CPPLOGE_STR_APPEND_CAUSE(_msg) \
+ BT_CPPLOGE_STR_APPEND_CAUSE_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg))
/*
* Calls logErrorAndThrow() on `_logger` to log an error, append a cause
#define BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW(_msg) \
BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg))
+/*
+ * Calls logErrno() on `_logger` with the `Level::Error` level to log an
+ * error and append a cause to the error of the current thread.
+ */
+#define BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC(_logger, _init_msg, _fmt, ...) \
+ (_logger).logErrno<bt2c::Logger::Level::Error, true>(__FILE__, __func__, __LINE__, \
+ (_init_msg), (_fmt), ##__VA_ARGS__)
+
+/*
+ * BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC() using the default logger.
+ */
+#define BT_CPPLOGE_ERRNO_APPEND_CAUSE(_init_msg, _fmt, ...) \
+ BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_fmt), ##__VA_ARGS__)
+
+/*
+ * Calls logErrnoStr() on `_logger` with the `Level::Error` level to log
+ * an error and append a cause to the error of the current thread.
+ */
+#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_SPEC(_logger, _init_msg, _msg) \
+ (_logger).logErrnoStr<bt2c::Logger::Level::Error, true>(__FILE__, __func__, __LINE__, \
+ (_init_msg), (_msg))
+
+/*
+ * BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_SPEC() using the default logger.
+ */
+#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE(_init_msg, _msg) \
+ BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_msg))
+
/*
* Calls logErrorErrnoAndThrow() on `_logger` to log an error, append a
* cause to the error of the current thread, and throw an instance of