* `tag`.
*/
explicit Logger(const bt2::SelfComponent selfComp, std::string tag) noexcept :
- _mSelfComp {selfComp}, _mLevel {static_cast<Level>(selfComp.loggingLevel())}, _mTag {
- std::move(
- tag)}
+ _mSelfComp {selfComp}, _mLevel {static_cast<Level>(selfComp.loggingLevel())},
+ _mTag {std::move(tag)}
{
}
*/
explicit Logger(const Logger& other, std::string newTag) :
_mSelfCompCls {other._mSelfCompCls}, _mSelfComp {other._mSelfComp},
- _mSelfMsgIter {other._mSelfMsgIter},
- _mModuleName {other._mModuleName}, _mLevel {other._mLevel}, _mTag {std::move(newTag)}
+ _mSelfMsgIter {other._mSelfMsgIter}, _mModuleName {other._mModuleName},
+ _mLevel {other._mLevel}, _mTag {std::move(newTag)}
{
}
return _mLevel;
}
- /*
- * Current logging level converted to a `bt_log_level` value.
- *
- * For legacy code.
- */
- bt_log_level cLevel() const noexcept
- {
- return static_cast<bt_log_level>(_mLevel);
- }
-
/*
* Whether or not this logger would log at the level `level`.
*/
*/
template <Level LevelV, bool AppendCauseV, typename... ArgTs>
void log(const char * const fileName, const char * const funcName, const unsigned int lineNo,
- const char * const fmt, ArgTs&&...args) const
+ fmt::format_string<ArgTs...> fmt, ArgTs&&...args) const
{
- this->_log<_StdLogWriter, LevelV, AppendCauseV>(fileName, funcName, lineNo, {}, "", fmt,
- std::forward<ArgTs>(args)...);
+ this->_log<_StdLogWriter, LevelV, AppendCauseV>(
+ fileName, funcName, lineNo, {}, "", std::move(fmt), std::forward<ArgTs>(args)...);
}
/*
*/
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,
+ const unsigned int lineNo, fmt::format_string<ArgTs...> fmt,
ArgTs&&...args) const
{
- this->log<Level::Error, AppendCauseV>(fileName, funcName, lineNo, fmt,
+ this->log<Level::Error, AppendCauseV>(fileName, funcName, lineNo, std::move(fmt),
std::forward<ArgTs>(args)...);
throw ExcT {};
}
*/
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
+ const unsigned int lineNo,
+ fmt::format_string<ArgTs...> fmt, ArgTs&&...args) const
{
- this->log<Level::Error, AppendCauseV>(fileName, funcName, lineNo, fmt,
+ this->log<Level::Error, AppendCauseV>(fileName, funcName, lineNo, std::move(fmt),
std::forward<ArgTs>(args)...);
throw;
}
*/
template <Level LevelV, bool AppendCauseV, typename... ArgTs>
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
+ const unsigned int lineNo, const char * const initMsg,
+ fmt::format_string<ArgTs...> fmt, ArgTs&&...args) const
{
- this->_log<_InitMsgLogWriter, LevelV, AppendCauseV>(fileName, funcName, lineNo, {},
- this->_errnoIntroStr(initMsg).c_str(),
- fmt, std::forward<ArgTs>(args)...);
+ this->_log<_InitMsgLogWriter, LevelV, AppendCauseV>(
+ fileName, funcName, lineNo, {}, this->_errnoIntroStr(initMsg).c_str(), std::move(fmt),
+ std::forward<ArgTs>(args)...);
}
/*
template <bool AppendCauseV, typename ExcT, typename... ArgTs>
[[noreturn]] void logErrorErrnoAndThrow(const char * const fileName,
const char * const funcName, const unsigned int lineNo,
- const char * const initMsg, const char * const fmt,
- ArgTs&&...args) const
+ const char * const initMsg,
+ fmt::format_string<ArgTs...> fmt, ArgTs&&...args) const
{
- this->logErrno<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg, fmt,
- std::forward<ArgTs>(args)...);
+ this->logErrno<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg,
+ std::move(fmt), std::forward<ArgTs>(args)...);
throw ExcT {};
}
* Like logErrno() with the `Level::Error` level, but also rethrows.
*/
template <bool AppendCauseV, typename... ArgTs>
- [[noreturn]] void logErrorErrnoAndRethrow(const char * const fileName,
- const char * const funcName,
- const unsigned int lineNo, const char * const initMsg,
- const char * const fmt, ArgTs&&...args) const
+ [[noreturn]] void
+ logErrorErrnoAndRethrow(const char * const fileName, const char * const funcName,
+ const unsigned int lineNo, const char * const initMsg,
+ fmt::format_string<ArgTs...> fmt, ArgTs&&...args) const
{
- this->logErrno<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg, fmt,
- std::forward<ArgTs>(args)...);
+ this->logErrno<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg,
+ std::move(fmt), std::forward<ArgTs>(args)...);
throw;
}
*/
template <Level LevelV, typename... ArgTs>
void logMem(const char * const fileName, const char * const funcName, const unsigned int lineNo,
- const MemData memData, const char * const fmt, ArgTs&&...args) const
+ const MemData memData, fmt::format_string<ArgTs...> fmt, ArgTs&&...args) const
{
- this->_log<_MemLogWriter, LevelV, false>(fileName, funcName, lineNo, memData, "", fmt,
- std::forward<ArgTs>(args)...);
+ this->_log<_MemLogWriter, LevelV, false>(fileName, funcName, lineNo, memData, "",
+ std::move(fmt), std::forward<ArgTs>(args)...);
}
private:
*/
template <typename LogWriterT, Level LevelV, bool AppendCauseV, typename... ArgTs>
void _log(const char * const fileName, const char * const funcName, const unsigned int lineNo,
- const MemData memData, const char * const initMsg, const char * const fmt,
+ const MemData memData, const char * const initMsg, fmt::format_string<ArgTs...> fmt,
ArgTs&&...args) const
{
const auto wouldLog = this->wouldLog(LevelV);
* append a null character).
*/
_mBuf.clear();
- BT_ASSERT(fmt);
- fmt::format_to(std::back_inserter(_mBuf), fmt, std::forward<ArgTs>(args)...);
+ fmt::format_to(std::back_inserter(_mBuf), std::move(fmt), std::forward<ArgTs>(args)...);
_mBuf.push_back('\0');
}