From e27adb90396a8c985b7d27004f82c56ff9c31b3d Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 25 Apr 2024 00:05:09 -0400 Subject: [PATCH] cpp-common/bt2c/logging.hpp: remove no-formatting ("str") alternatives MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch removes everything named bt2c::Logger::log*Str*() and BT_CPPLOG*STR*(). The no-formatting versions existed to avoid a call to fmt::format_to() when you need to log a literal string as is, without any formatting. It was also useful to pass a user string as is. However, in the end, I don't think such an optimization is necessary: • We don't use the no-formatting versions that much compared to messages with a format string. • fmt::format_to() is pretty fast without any replacement field. • We're talking about logging performance. • This patch removes a lot of often redudant code from `logging.hpp`. Adapt the current no-formatting logging calls accordingly. Signed-off-by: Philippe Proulx Change-Id: Ie02ea492e220c7ce9b72aaf8728fb7d2211e0bc0 Reviewed-on: https://review.lttng.org/c/babeltrace/+/12479 Reviewed-by: Simon Marchi Tested-by: jenkins --- src/cpp-common/bt2c/logging.hpp | 345 +----------------- src/plugins/ctf/common/src/bfcr/bfcr.cpp | 20 +- .../src/metadata/tsdl/ctf-meta-resolve.cpp | 2 +- .../decoder-packetized-file-stream-to-buf.cpp | 2 +- .../ctf/common/src/metadata/tsdl/lexer.lpp | 2 +- .../ctf/common/src/metadata/tsdl/objstack.cpp | 4 +- .../ctf/common/src/metadata/tsdl/parser.ypp | 5 +- .../src/metadata/tsdl/visitor-generate-ir.cpp | 4 +- .../ctf/common/src/msg-iter/msg-iter.cpp | 14 +- src/plugins/ctf/fs-sink/fs-sink-trace.cpp | 36 +- src/plugins/ctf/fs-sink/fs-sink.cpp | 3 +- .../fs-sink/translate-trace-ir-to-ctf-ir.cpp | 12 +- src/plugins/ctf/fs-src/data-stream-file.cpp | 25 +- src/plugins/ctf/fs-src/fs.cpp | 14 +- src/plugins/ctf/lttng-live/lttng-live.cpp | 2 +- src/plugins/utils/muxer/comp.cpp | 8 +- src/plugins/utils/muxer/msg-iter.cpp | 9 +- 17 files changed, 97 insertions(+), 410 deletions(-) diff --git a/src/cpp-common/bt2c/logging.hpp b/src/cpp-common/bt2c/logging.hpp index 90db909b..970ff9b7 100644 --- a/src/cpp-common/bt2c/logging.hpp +++ b/src/cpp-common/bt2c/logging.hpp @@ -291,19 +291,6 @@ public: std::forward(args)...); } - /* - * Logs `msg` using the level `LevelV`. - * - * If `AppendCauseV` is true, this method also appends a cause to - * the error of the current thread using the same message. - */ - template - void logStr(const char * const fileName, const char * const funcName, const unsigned int lineNo, - const char * const msg) const - { - this->_logStr<_StdLogWriter, LevelV, AppendCauseV>(fileName, funcName, lineNo, {}, "", msg); - } - /* * Like log() with the `Level::Error` level, but also throws a * default-constructed instance of `ExcT`. @@ -318,18 +305,6 @@ public: throw ExcT {}; } - /* - * Like logStr() with the `Level::Error` level, but also throws a - * default-constructed instance of `ExcT`. - */ - template - [[noreturn]] void logErrorStrAndThrow(const char * const fileName, const char * const funcName, - const unsigned int lineNo, const char * const msg) const - { - this->logStr(fileName, funcName, lineNo, msg); - throw ExcT {}; - } - /* * Like log() with the `Level::Error` level, but also rethrows. */ @@ -343,18 +318,6 @@ public: throw; } - /* - * Like logStr() with the `Level::Error` level, but also rethrows. - */ - template - [[noreturn]] void logErrorStrAndRethrow(const char * const fileName, - const char * const funcName, const unsigned int lineNo, - const char * const msg) const - { - this->logStr(fileName, funcName, lineNo, msg); - throw; - } - private: struct _InitMsgLogWriter final { @@ -388,24 +351,6 @@ public: fmt, std::forward(args)...); } - /* - * Logs the message of `errno` using the level `LevelV`. - * - * The log message starts with `initMsg`, is followed with the - * message for `errno`, and then with `msg`. - * - * If `AppendCauseV` is true, this method also appends a cause to - * the error of the current thread using the same message. - */ - template - void logErrnoStr(const char * const fileName, const char * const funcName, - const unsigned int lineNo, const char * const initMsg, - const char * const msg) const - { - this->_logStr<_InitMsgLogWriter, LevelV, AppendCauseV>( - fileName, funcName, lineNo, {}, this->_errnoIntroStr(initMsg).c_str(), msg); - } - /* * Like logErrno() with the `Level::Error` level, but also throws a * default-constructed instance of `ExcT`. @@ -421,20 +366,6 @@ public: throw ExcT {}; } - /* - * Like logErrnoStr() with the `Level::Error` level, but also throws - * a default-constructed instance of `ExcT`. - */ - template - [[noreturn]] void - logErrorErrnoStrAndThrow(const char * const fileName, const char * const funcName, - const unsigned int lineNo, const char * const initMsg, - const char * const msg) const - { - this->logErrnoStr(fileName, funcName, lineNo, initMsg, msg); - throw ExcT {}; - } - /* * Like logErrno() with the `Level::Error` level, but also rethrows. */ @@ -449,20 +380,6 @@ public: throw; } - /* - * Like logErrnoStr() with the `Level::Error` level, but also - * rethrows. - */ - template - [[noreturn]] void - logErrorErrnoStrAndRethrow(const char * const fileName, const char * const funcName, - const unsigned int lineNo, const char * const initMsg, - const char * const msg) const - { - this->logErrnoStr(fileName, funcName, lineNo, initMsg, msg); - throw; - } - private: struct _MemLogWriter final { @@ -490,80 +407,61 @@ public: std::forward(args)...); } - /* - * Logs memory data using the level `LevelV`, starting with the - * message `msg`. - */ - template - void logMemStr(const char * const fileName, const char * const funcName, - const unsigned int lineNo, const MemData memData, const char * const msg) const - { - this->_logStr<_MemLogWriter, LevelV, false>(fileName, funcName, lineNo, memData, "", msg); - } - private: /* * Formats a log message with fmt::format() given `fmt` and `args`, - * and then forwards everything to _logStr(). + * and then: + * + * 1. Calls LogWriterT::write() with its arguments to log using the + * level `LevelV`. + * + * 2. If `AppendCauseV` is true, this method also appends a cause to + * the error of the current thread using the concatenation of + * `initMsg` and `msg` as the message. */ template 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, ArgTs&&...args) const { + const auto wouldLog = this->wouldLog(LevelV); + /* Only format arguments if logging or appending an error cause */ - if (G_UNLIKELY(this->wouldLog(LevelV) || AppendCauseV)) { + if (G_UNLIKELY(wouldLog || AppendCauseV)) { /* * Format arguments to our buffer (fmt::format_to() doesn't * append a null character). */ _mBuf.clear(); + BT_ASSERT(fmt); fmt::format_to(std::back_inserter(_mBuf), fmt, std::forward(args)...); _mBuf.push_back('\0'); } - this->_logStr(fileName, funcName, lineNo, memData, - initMsg, _mBuf.data()); - } - - /* - * Calls LogWriterT::write() with its arguments to log using the - * level `LevelV`. - * - * If `AppendCauseV` is true, this method also appends a cause to - * the error of the current thread using the concatenation of - * `initMsg` and `msg` as the message. - */ - template - void _logStr(const char * const fileName, const char * const funcName, - const unsigned int lineNo, const MemData memData, const char * const initMsg, - const char * const msg) const - { - /* Initial message and main message are required */ + /* Initial message is required */ BT_ASSERT(initMsg); - BT_ASSERT(msg); /* Log if needed */ - if (this->wouldLog(LevelV)) { + if (wouldLog) { LogWriterT::write(fileName, funcName, lineNo, LevelV, _mTag.data(), memData, initMsg, - msg); + _mBuf.data()); } /* Append an error cause if needed */ if (AppendCauseV) { if (_mSelfMsgIter) { bt_current_thread_error_append_cause_from_message_iterator( - _mSelfMsgIter->libObjPtr(), fileName, lineNo, "%s%s", initMsg, msg); + _mSelfMsgIter->libObjPtr(), fileName, lineNo, "%s%s", initMsg, _mBuf.data()); } else if (_mSelfComp) { bt_current_thread_error_append_cause_from_component( - _mSelfComp->libObjPtr(), fileName, lineNo, "%s%s", initMsg, msg); + _mSelfComp->libObjPtr(), fileName, lineNo, "%s%s", initMsg, _mBuf.data()); } else if (_mSelfCompCls) { bt_current_thread_error_append_cause_from_component_class( - _mSelfCompCls->libObjPtr(), fileName, lineNo, "%s%s", initMsg, msg); + _mSelfCompCls->libObjPtr(), fileName, lineNo, "%s%s", initMsg, _mBuf.data()); } else { BT_ASSERT(_mModuleName); - bt_current_thread_error_append_cause_from_unknown(_mModuleName->data(), fileName, - lineNo, "%s%s", initMsg, msg); + bt_current_thread_error_append_cause_from_unknown( + _mModuleName->data(), fileName, lineNo, "%s%s", initMsg, _mBuf.data()); } } } @@ -641,39 +539,6 @@ inline const char *maybeNull(const char * const s) noexcept #define BT_CPPLOGE(_fmt, ...) BT_CPPLOGE_SPEC(_BT_CPPLOG_DEF_LOGGER, (_fmt), ##__VA_ARGS__) #define BT_CPPLOGF(_fmt, ...) BT_CPPLOGF_SPEC(_BT_CPPLOG_DEF_LOGGER, (_fmt), ##__VA_ARGS__) -/* - * Calls logStr() on `_logger` to log using the level `_lvl`. - */ -#define BT_CPPLOG_STR_EX(_lvl, _logger, _msg) \ - (_logger).template 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)) -#define BT_CPPLOGD_STR_SPEC(_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)) -#define BT_CPPLOGW_STR_SPEC(_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)) -#define BT_CPPLOGF_STR_SPEC(_logger, _msg) \ - BT_CPPLOG_STR_EX(bt2c::Logger::Level::Fatal, (_logger), (_msg)) - -/* - * BT_CPPLOG_STR_EX() with specific logging levels and using the default - * logger. - */ -#define BT_CPPLOGT_STR(_msg) BT_CPPLOGT_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg)) -#define BT_CPPLOGD_STR(_msg) BT_CPPLOGD_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg)) -#define BT_CPPLOGI_STR(_msg) BT_CPPLOGI_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg)) -#define BT_CPPLOGW_STR(_msg) BT_CPPLOGW_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg)) -#define BT_CPPLOGE_STR(_msg) BT_CPPLOGE_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg)) -#define BT_CPPLOGF_STR(_msg) BT_CPPLOGF_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg)) - /* * Calls logMem() on `_logger` to log using the level `_lvl`. */ @@ -718,45 +583,6 @@ inline const char *maybeNull(const char * const s) noexcept #define BT_CPPLOGF_MEM(_memData, _fmt, ...) \ BT_CPPLOGF_MEM_SPEC(_BT_CPPLOG_DEF_LOGGER, (_memData), (_fmt), ##__VA_ARGS__) -/* - * Calls logMemStr() on `_logger` to log using the level `_lvl`. - */ -#define BT_CPPLOG_MEM_STR_EX(_lvl, _logger, _memData, _msg) \ - (_logger).template logMemStr<(_lvl)>(__FILE__, __func__, __LINE__, (_memData), (_msg)) - -/* - * BT_CPPLOG_MEM_STR_EX() with specific logging levels. - */ -#define BT_CPPLOGT_MEM_STR_SPEC(_logger, _memData, _msg) \ - BT_CPPLOG_MEM_STR_EX(bt2c::Logger::Level::TRACE, (_logger), (_memData), (_msg)) -#define BT_CPPLOGD_MEM_STR_SPEC(_logger, _memData, _msg) \ - BT_CPPLOG_MEM_STR_EX(bt2c::Logger::Level::DEBUG, (_logger), (_memData), (_msg)) -#define BT_CPPLOGI_MEM_STR_SPEC(_logger, _memData, _msg) \ - BT_CPPLOG_MEM_STR_EX(bt2c::Logger::Level::INFO, (_logger), (_memData), (_msg)) -#define BT_CPPLOGW_MEM_STR_SPEC(_logger, _memData, _msg) \ - BT_CPPLOG_MEM_STR_EX(bt2c::Logger::Level::WARNING, (_logger), (_memData), (_msg)) -#define BT_CPPLOGE_MEM_STR_SPEC(_logger, _memData, _msg) \ - BT_CPPLOG_MEM_STR_EX(bt2c::Logger::Level::Error, (_logger), (_memData), (_msg)) -#define BT_CPPLOGF_MEM_STR_SPEC(_logger, _memData, _msg) \ - BT_CPPLOG_MEM_STR_EX(bt2c::Logger::Level::FATAL, (_logger), (_memData), (_msg)) - -/* - * BT_CPPLOG_MEM_STR_EX() with specific logging levels and using the - * default logger. - */ -#define BT_CPPLOGT_MEM_STR(_memData, _msg) \ - BT_CPPLOGT_MEM_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_memData), (_msg)) -#define BT_CPPLOGD_MEM_STR(_memData, _msg) \ - BT_CPPLOGD_MEM_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_memData), (_msg)) -#define BT_CPPLOGI_MEM_STR(_memData, _msg) \ - BT_CPPLOGI_MEM_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_memData), (_msg)) -#define BT_CPPLOGW_MEM_STR(_memData, _msg) \ - BT_CPPLOGW_MEM_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_memData), (_msg)) -#define BT_CPPLOGE_MEM_STR(_memData, _msg) \ - BT_CPPLOGE_MEM_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_memData), (_msg)) -#define BT_CPPLOGF_MEM_STR(_memData, _msg) \ - BT_CPPLOGF_MEM_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_memData), (_msg)) - /* * Calls logErrno() on `_logger` to log using the level `_lvl` and * initial message `_initMsg`. @@ -802,46 +628,6 @@ inline const char *maybeNull(const char * const s) noexcept #define BT_CPPLOGF_ERRNO(_initMsg, _fmt, ...) \ BT_CPPLOGF_ERRNO_SPEC(_BT_CPPLOG_DEF_LOGGER, (_initMsg), (_fmt), ##__VA_ARGS__) -/* - * Calls logErrnoStr() on `_logger` to log using the level `_lvl` and - * initial message `_initMsg`. - */ -#define BT_CPPLOG_ERRNO_STR_EX(_lvl, _logger, _initMsg, _msg) \ - (_logger).template logErrnoStr<(_lvl), false>(__FILE__, __func__, __LINE__, (_initMsg), (_msg)) - -/* - * BT_CPPLOG_ERRNO_STR_EX() with specific logging levels. - */ -#define BT_CPPLOGT_ERRNO_STR_SPEC(_logger, _initMsg, _msg) \ - BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Trace, (_logger), (_initMsg), (_msg)) -#define BT_CPPLOGD_ERRNO_STR_SPEC(_logger, _initMsg, _msg) \ - BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Debug, (_logger), (_initMsg), (_msg)) -#define BT_CPPLOGI_ERRNO_STR_SPEC(_logger, _initMsg, _msg) \ - BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Info, (_logger), (_initMsg), (_msg)) -#define BT_CPPLOGW_ERRNO_STR_SPEC(_logger, _initMsg, _msg) \ - BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Warning, (_logger), (_initMsg), (_msg)) -#define BT_CPPLOGE_ERRNO_STR_SPEC(_logger, _initMsg, _msg) \ - BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Error, (_logger), (_initMsg), (_msg)) -#define BT_CPPLOGF_ERRNO_STR_SPEC(_logger, _initMsg, _msg) \ - BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Fatal, (_logger), (_initMsg), (_msg)) - -/* - * BT_CPPLOG_ERRNO_STR_EX() with specific logging levels and using the - * default logger. - */ -#define BT_CPPLOGT_ERRNO_STR(_initMsg, _msg) \ - BT_CPPLOGT_ERRNO_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_initMsg), (_msg)) -#define BT_CPPLOGD_ERRNO_STR(_initMsg, _msg) \ - BT_CPPLOGD_ERRNO_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_initMsg), (_msg)) -#define BT_CPPLOGI_ERRNO_STR(_initMsg, _msg) \ - BT_CPPLOGI_ERRNO_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_initMsg), (_msg)) -#define BT_CPPLOGW_ERRNO_STR(_initMsg, _msg) \ - BT_CPPLOGW_ERRNO_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_initMsg), (_msg)) -#define BT_CPPLOGE_ERRNO_STR(_initMsg, _msg) \ - BT_CPPLOGE_ERRNO_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_initMsg), (_msg)) -#define BT_CPPLOGF_ERRNO_STR(_initMsg, _msg) \ - BT_CPPLOGF_ERRNO_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_initMsg), (_msg)) - /* * Calls log() on `_logger` with the `Error` level to log an error and * append a cause to the error of the current thread. @@ -856,20 +642,6 @@ inline const char *maybeNull(const char * const s) noexcept #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).template logStr(__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 * to the error of the current thread, and throw an instance of @@ -885,21 +657,6 @@ inline const char *maybeNull(const char * const s) noexcept #define BT_CPPLOGE_APPEND_CAUSE_AND_THROW(_excCls, _fmt, ...) \ BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(_BT_CPPLOG_DEF_LOGGER, _excCls, (_fmt), ##__VA_ARGS__) -/* - * Calls logErrorStrAndThrow() on `_logger` to log an error, append a - * cause to the error of the current thread, and throw an instance of - * `_excCls`. - */ -#define BT_CPPLOGE_STR_APPEND_CAUSE_AND_THROW_SPEC(_logger, _excCls, _msg) \ - (_logger).template logErrorStrAndThrow(__FILE__, __func__, __LINE__, (_msg)) - -/* - * BT_CPPLOGE_STR_APPEND_CAUSE_AND_THROW_SPEC() using the default - * logger. - */ -#define BT_CPPLOGE_STR_APPEND_CAUSE_AND_THROW(_excCls, _msg) \ - BT_CPPLOGE_STR_APPEND_CAUSE_AND_THROW_SPEC(_BT_CPPLOG_DEF_LOGGER, _excCls, (_msg)) - /* * Calls logErrorAndRethrow() on `_logger` to log an error, append a * cause to the error of the current thread, and throw an instance of @@ -914,21 +671,6 @@ inline const char *maybeNull(const char * const s) noexcept #define BT_CPPLOGE_APPEND_CAUSE_AND_RETHROW(_fmt, ...) \ BT_CPPLOGE_APPEND_CAUSE_AND_RETHROW_SPEC(_BT_CPPLOG_DEF_LOGGER, (_fmt), ##__VA_ARGS__) -/* - * Calls logErrorStrAndRethrow() on `_logger` to log an error, append a - * cause to the error of the current thread, and throw an instance of - * `_excCls`. - */ -#define BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW_SPEC(_logger, _msg) \ - (_logger).template logErrorStrAndRethrow(__FILE__, __func__, __LINE__, (_msg)) - -/* - * BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW_SPEC() using the default - * logger. - */ -#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. @@ -943,20 +685,6 @@ inline const char *maybeNull(const char * const s) noexcept #define BT_CPPLOGE_ERRNO_APPEND_CAUSE(_initMsg, _fmt, ...) \ BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC(_BT_CPPLOG_DEF_LOGGER, (_initMsg), (_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, _initMsg, _msg) \ - (_logger).template logErrnoStr(__FILE__, __func__, __LINE__, \ - (_initMsg), (_msg)) - -/* - * BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_SPEC() using the default logger. - */ -#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE(_initMsg, _msg) \ - BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_SPEC(_BT_CPPLOG_DEF_LOGGER, (_initMsg), (_msg)) - /* * Calls logErrorErrnoAndThrow() on `_logger` to log an error, append a * cause to the error of the current thread, and throw an instance of @@ -974,23 +702,6 @@ inline const char *maybeNull(const char * const s) noexcept BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_THROW_SPEC(_BT_CPPLOG_DEF_LOGGER, _excCls, (_initMsg), \ (_fmt), ##__VA_ARGS__) -/* - * Calls logErrorErrnoStrAndThrow() on `_logger` to log an error, append - * a cause to the error of the current thread, and throw an instance of - * `_excCls`. - */ -#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_THROW_SPEC(_logger, _excCls, _initMsg, _msg) \ - (_logger).template logErrorErrnoStrAndThrow(__FILE__, __func__, __LINE__, \ - (_initMsg), (_msg)) - -/* - * BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_THROW_SPEC() using the default - * logger. - */ -#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_THROW(_excCls, _initMsg, _msg) \ - BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_THROW_SPEC(_BT_CPPLOG_DEF_LOGGER, _excCls, (_initMsg), \ - (_msg)) - /* * Calls logErrorErrnoAndRethrow() on `_logger` to log an error, append * a cause to the error of the current thread, and throw an instance of @@ -1008,20 +719,4 @@ inline const char *maybeNull(const char * const s) noexcept BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_RETHROW_SPEC(_BT_CPPLOG_DEF_LOGGER, (_initMsg), (_fmt), \ ##__VA_ARGS__) -/* - * Calls logErrorErrnoStrAndRethrow() on `_logger` to log an error, - * append a cause to the error of the current thread, and throw an - * instance of `_excCls`. - */ -#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_RETHROW_SPEC(_logger, _initMsg, _msg) \ - (_logger).template logErrorErrnoStrAndRethrow(__FILE__, __func__, __LINE__, (_initMsg), \ - (_msg)) - -/* - * BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_RETHROW_SPEC() using the - * default logger. - */ -#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_RETHROW(_initMsg, _msg) \ - BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_RETHROW_SPEC(_BT_CPPLOG_DEF_LOGGER, (_initMsg), (_msg)) - #endif /* BABELTRACE_CPP_COMMON_BT2C_LOGGING_HPP */ diff --git a/src/plugins/ctf/common/src/bfcr/bfcr.cpp b/src/plugins/ctf/common/src/bfcr/bfcr.cpp index 2b5cb79a..4ee3548c 100644 --- a/src/plugins/ctf/common/src/bfcr/bfcr.cpp +++ b/src/plugins/ctf/common/src/bfcr/bfcr.cpp @@ -176,14 +176,14 @@ static struct stack *stack_new(struct bt_bfcr *bfcr) stack = g_new0(struct stack, 1); if (!stack) { - BT_CPPLOGE_STR_SPEC(bfcr->logger, "Failed to allocate one stack."); + BT_CPPLOGE_SPEC(bfcr->logger, "Failed to allocate one stack."); goto error; } stack->bfcr = bfcr; stack->entries = g_array_new(FALSE, TRUE, sizeof(struct stack_entry)); if (!stack->entries) { - BT_CPPLOGE_STR_SPEC(bfcr->logger, "Failed to allocate a GArray."); + BT_CPPLOGE_SPEC(bfcr->logger, "Failed to allocate a GArray."); goto error; } @@ -675,8 +675,8 @@ read_bit_array_class_and_call_continue(struct bt_bfcr *bfcr, } /* We are here; it means we don't have enough data to decode this */ - BT_CPPLOGT_STR_SPEC( - bfcr->logger, "Not enough data to read the next basic field: appending to stitch buffer."); + BT_CPPLOGT_SPEC(bfcr->logger, + "Not enough data to read the next basic field: appending to stitch buffer."); stitch_append_from_remaining_buf(bfcr); status = BT_BFCR_STATUS_EOF; @@ -734,8 +734,8 @@ read_bit_array_class_and_call_begin(struct bt_bfcr *bfcr, } /* We are here; it means we don't have enough data to decode this */ - BT_CPPLOGT_STR_SPEC(bfcr->logger, - "Not enough data to read the next basic field: setting stitch buffer."); + BT_CPPLOGT_SPEC(bfcr->logger, + "Not enough data to read the next basic field: setting stitch buffer."); stitch_set_from_remaining_buf(bfcr); bfcr->state = BFCR_STATE_READ_BASIC_CONTINUE; status = BT_BFCR_STATUS_EOF; @@ -1116,12 +1116,12 @@ static inline enum bt_bfcr_status handle_state(struct bt_bfcr *bfcr) struct bt_bfcr *bt_bfcr_create(struct bt_bfcr_cbs cbs, void *data, const bt2c::Logger& logger) { - BT_CPPLOGD_STR_SPEC(logger, "Creating binary field class reader (BFCR)."); + BT_CPPLOGD_SPEC(logger, "Creating binary field class reader (BFCR)."); bt_bfcr *bfcr = new bt_bfcr {logger}; bfcr->stack = stack_new(bfcr); if (!bfcr->stack) { - BT_CPPLOGE_STR_SPEC(bfcr->logger, "Cannot create BFCR's stack."); + BT_CPPLOGE_SPEC(bfcr->logger, "Cannot create BFCR's stack."); bt_bfcr_destroy(bfcr); bfcr = NULL; goto end; @@ -1216,7 +1216,7 @@ size_t bt_bfcr_start(struct bt_bfcr *bfcr, struct ctf_field_class *cls, const ui } /* Run the machine! */ - BT_CPPLOGT_STR_SPEC(bfcr->logger, "Running the state machine."); + BT_CPPLOGT_SPEC(bfcr->logger, "Running the state machine."); while (true) { *status = handle_state(bfcr); @@ -1249,7 +1249,7 @@ size_t bt_bfcr_continue(struct bt_bfcr *bfcr, const uint8_t *buf, size_t sz, fmt::ptr(bfcr), fmt::ptr(buf), sz); /* Continue running the machine */ - BT_CPPLOGT_STR_SPEC(bfcr->logger, "Running the state machine."); + BT_CPPLOGT_SPEC(bfcr->logger, "Running the state machine."); while (true) { *status = handle_state(bfcr); diff --git a/src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-resolve.cpp b/src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-resolve.cpp index 0de4c675..4420746a 100644 --- a/src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-resolve.cpp +++ b/src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-resolve.cpp @@ -550,7 +550,7 @@ static int relative_ptokens_to_field_path(GList *ptokens, struct ctf_field_path ret = ptokens_to_field_path(ptokens, &tail_field_path, parent_class, cur_index, ctx); if (ret) { /* Not found... yet */ - BT_CPPLOGD_STR_SPEC(ctx->logger, "Not found at this point."); + BT_CPPLOGD_SPEC(ctx->logger, "Not found at this point."); ctf_field_path_clear(&tail_field_path); } else { /* Found: stitch tail field path to head field path */ diff --git a/src/plugins/ctf/common/src/metadata/tsdl/decoder-packetized-file-stream-to-buf.cpp b/src/plugins/ctf/common/src/metadata/tsdl/decoder-packetized-file-stream-to-buf.cpp index 846df316..b6de4d61 100644 --- a/src/plugins/ctf/common/src/metadata/tsdl/decoder-packetized-file-stream-to-buf.cpp +++ b/src/plugins/ctf/common/src/metadata/tsdl/decoder-packetized-file-stream-to-buf.cpp @@ -165,7 +165,7 @@ static int decode_packet(FILE *in_fp, FILE *out_fp, int byte_order, bool *is_uui toread = (header.packet_size - header.content_size) / CHAR_BIT; fseek_ret = fseek(in_fp, toread, SEEK_CUR); if (fseek_ret < 0) { - BT_CPPLOGW_STR_SPEC(logger, "Missing padding at the end of the metadata stream."); + BT_CPPLOGW_SPEC(logger, "Missing padding at the end of the metadata stream."); } break; } diff --git a/src/plugins/ctf/common/src/metadata/tsdl/lexer.lpp b/src/plugins/ctf/common/src/metadata/tsdl/lexer.lpp index 826cca14..8bc0eeda 100644 --- a/src/plugins/ctf/common/src/metadata/tsdl/lexer.lpp +++ b/src/plugins/ctf/common/src/metadata/tsdl/lexer.lpp @@ -12,7 +12,7 @@ #include "plugins/ctf/common/src/metadata/tsdl/parser-wrap.hpp" #include "plugins/ctf/common/src/metadata/tsdl/scanner.hpp" -#define YY_FATAL_ERROR(_msg) BT_CPPLOGF_STR_SPEC(currentCtfScanner->logger, _msg) +#define YY_FATAL_ERROR(_msg) BT_CPPLOGF_SPEC(currentCtfScanner->logger, "{}", _msg) #define PARSE_INTEGER_LITERAL(base) \ do { \ diff --git a/src/plugins/ctf/common/src/metadata/tsdl/objstack.cpp b/src/plugins/ctf/common/src/metadata/tsdl/objstack.cpp index cb13f63b..d124b3f3 100644 --- a/src/plugins/ctf/common/src/metadata/tsdl/objstack.cpp +++ b/src/plugins/ctf/common/src/metadata/tsdl/objstack.cpp @@ -45,7 +45,7 @@ objstack *objstack_create(const bt2c::Logger& parentLogger) objstack = new ::objstack {parentLogger}; node = (objstack_node *) calloc(sizeof(struct objstack_node) + OBJSTACK_INIT_LEN, sizeof(char)); if (!node) { - BT_CPPLOGE_STR_SPEC(objstack->logger, "Failed to allocate one object stack node."); + BT_CPPLOGE_SPEC(objstack->logger, "Failed to allocate one object stack node."); delete objstack; return NULL; } @@ -94,7 +94,7 @@ static struct objstack_node *objstack_append_node(struct objstack *objstack) new_node = (objstack_node *) calloc(sizeof(struct objstack_node) + (last_node->len << 1), sizeof(char)); if (!new_node) { - BT_CPPLOGE_STR_SPEC(objstack->logger, "Failed to allocate one object stack node."); + BT_CPPLOGE_SPEC(objstack->logger, "Failed to allocate one object stack node."); return NULL; } bt_list_add_tail(&new_node->node, &objstack->head); diff --git a/src/plugins/ctf/common/src/metadata/tsdl/parser.ypp b/src/plugins/ctf/common/src/metadata/tsdl/parser.ypp index 7ae25b69..bf2d90c5 100644 --- a/src/plugins/ctf/common/src/metadata/tsdl/parser.ypp +++ b/src/plugins/ctf/common/src/metadata/tsdl/parser.ypp @@ -31,7 +31,7 @@ thread_local const ctf_scanner *currentCtfScanner; std::string str(size, '\0'); \ int written = snprintf(&str[0], size + 1, (_fmt), ##args); \ BT_ASSERT(size == written); \ - BT_CPPLOGT_STR_SPEC(currentCtfScanner->logger, str.c_str()); \ + BT_CPPLOGT_SPEC(currentCtfScanner->logger, "{}", str.c_str()); \ } while (0) /* Join two lists, put "add" at the end of "head". */ @@ -803,8 +803,7 @@ static int set_parent_node(struct ctf_node *node, switch (node->type) { case NODE_ROOT: - BT_CPPLOGE_STR_SPEC(currentCtfScanner->logger, - "Trying to reparent root node."); + BT_CPPLOGE_SPEC(currentCtfScanner->logger, "Trying to reparent root node."); return -EINVAL; case NODE_EVENT: diff --git a/src/plugins/ctf/common/src/metadata/tsdl/visitor-generate-ir.cpp b/src/plugins/ctf/common/src/metadata/tsdl/visitor-generate-ir.cpp index 7900662a..48034a3f 100644 --- a/src/plugins/ctf/common/src/metadata/tsdl/visitor-generate-ir.cpp +++ b/src/plugins/ctf/common/src/metadata/tsdl/visitor-generate-ir.cpp @@ -4436,7 +4436,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *ctx, stru { int ret = 0; - BT_CPPLOGI_STR_SPEC(ctx->logger, "Visiting metadata's AST to generate CTF IR objects."); + BT_CPPLOGI_SPEC(ctx->logger, "Visiting metadata's AST to generate CTF IR objects."); switch (node->type) { case NODE_ROOT: @@ -4472,7 +4472,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *ctx, stru } if (!got_trace_decl) { - BT_CPPLOGD_STR_SPEC(ctx->logger, "Incomplete AST: need trace (`trace` block)."); + BT_CPPLOGD_SPEC(ctx->logger, "Incomplete AST: need trace (`trace` block)."); ret = -EINCOMPLETE; goto end; } diff --git a/src/plugins/ctf/common/src/msg-iter/msg-iter.cpp b/src/plugins/ctf/common/src/msg-iter/msg-iter.cpp index 1d146f3d..50a545bb 100644 --- a/src/plugins/ctf/common/src/msg-iter/msg-iter.cpp +++ b/src/plugins/ctf/common/src/msg-iter/msg-iter.cpp @@ -599,11 +599,11 @@ read_dscope_begin_state(struct ctf_msg_iter *msg_it, struct ctf_field_class *dsc switch (bfcr_status) { case BT_BFCR_STATUS_OK: /* Field class was read completely */ - BT_CPPLOGT_STR_SPEC(msg_it->logger, "Field was completely decoded."); + BT_CPPLOGT_SPEC(msg_it->logger, "Field was completely decoded."); msg_it->state = done_state; break; case BT_BFCR_STATUS_EOF: - BT_CPPLOGT_STR_SPEC(msg_it->logger, "BFCR needs more data to decode field completely."); + BT_CPPLOGT_SPEC(msg_it->logger, "BFCR needs more data to decode field completely."); msg_it->state = continue_state; break; default: @@ -655,12 +655,12 @@ static enum ctf_msg_iter_status read_dscope_continue_state(struct ctf_msg_iter * switch (bfcr_status) { case BT_BFCR_STATUS_OK: /* Type was read completely. */ - BT_CPPLOGT_STR_SPEC(msg_it->logger, "Field was completely decoded."); + BT_CPPLOGT_SPEC(msg_it->logger, "Field was completely decoded."); msg_it->state = done_state; break; case BT_BFCR_STATUS_EOF: /* Stay in this continue state. */ - BT_CPPLOGT_STR_SPEC(msg_it->logger, "BFCR needs more data to decode field completely."); + BT_CPPLOGT_SPEC(msg_it->logger, "BFCR needs more data to decode field completely."); break; default: BT_CPPLOGE_APPEND_CAUSE_SPEC(msg_it->logger, @@ -2728,7 +2728,7 @@ void ctf_msg_iter_destroy(struct ctf_msg_iter *msg_it) fmt::ptr(msg_it)); if (msg_it->stack) { - BT_CPPLOGD_STR_SPEC(msg_it->logger, "Destroying field stack."); + BT_CPPLOGD_SPEC(msg_it->logger, "Destroying field stack."); stack_destroy(msg_it->stack); } @@ -2761,7 +2761,7 @@ enum ctf_msg_iter_status ctf_msg_iter_get_next_message(struct ctf_msg_iter *msg_ while (true) { status = handle_state(msg_it); if (G_UNLIKELY(status == CTF_MSG_ITER_STATUS_AGAIN)) { - BT_CPPLOGD_STR_SPEC(msg_it->logger, "Medium returned CTF_MSG_ITER_STATUS_AGAIN."); + BT_CPPLOGD_SPEC(msg_it->logger, "Medium returned CTF_MSG_ITER_STATUS_AGAIN."); goto end; } else if (G_UNLIKELY(status != CTF_MSG_ITER_STATUS_OK)) { BT_CPPLOGE_APPEND_CAUSE_SPEC(msg_it->logger, @@ -2895,7 +2895,7 @@ static enum ctf_msg_iter_status decode_until_state(struct ctf_msg_iter *msg_it, status = handle_state(msg_it); if (G_UNLIKELY(status == CTF_MSG_ITER_STATUS_AGAIN)) { - BT_CPPLOGD_STR_SPEC(msg_it->logger, "Medium returned CTF_MSG_ITER_STATUS_AGAIN."); + BT_CPPLOGD_SPEC(msg_it->logger, "Medium returned CTF_MSG_ITER_STATUS_AGAIN."); goto end; } else if (G_UNLIKELY(status != CTF_MSG_ITER_STATUS_OK)) { BT_CPPLOGE_APPEND_CAUSE_SPEC(msg_it->logger, diff --git a/src/plugins/ctf/fs-sink/fs-sink-trace.cpp b/src/plugins/ctf/fs-sink/fs-sink-trace.cpp index 79d4839a..cebf19f6 100644 --- a/src/plugins/ctf/fs-sink/fs-sink-trace.cpp +++ b/src/plugins/ctf/fs-sink/fs-sink-trace.cpp @@ -157,8 +157,8 @@ static int append_lttng_trace_path_ust_uid(const struct fs_sink_trace *trace, GS v = bt_trace_borrow_environment_entry_value_by_name_const(tc, "tracer_buffering_id"); if (!v || !bt_value_is_signed_integer(v)) { - BT_CPPLOGI_STR_SPEC(trace->logger, - "Couldn't get environment value: name=\"tracer_buffering_id\""); + BT_CPPLOGI_SPEC(trace->logger, + "Couldn't get environment value: name=\"tracer_buffering_id\""); goto error; } @@ -166,8 +166,8 @@ static int append_lttng_trace_path_ust_uid(const struct fs_sink_trace *trace, GS v = bt_trace_borrow_environment_entry_value_by_name_const(tc, "architecture_bit_width"); if (!v || !bt_value_is_signed_integer(v)) { - BT_CPPLOGI_STR_SPEC(trace->logger, - "Couldn't get environment value: name=\"architecture_bit_width\""); + BT_CPPLOGI_SPEC(trace->logger, + "Couldn't get environment value: name=\"architecture_bit_width\""); goto error; } @@ -193,7 +193,7 @@ static int append_lttng_trace_path_ust_pid(const struct fs_sink_trace *trace, GS v = bt_trace_borrow_environment_entry_value_by_name_const(tc, "procname"); if (!v || !bt_value_is_string(v)) { - BT_CPPLOGI_STR_SPEC(trace->logger, "Couldn't get environment value: name=\"procname\""); + BT_CPPLOGI_SPEC(trace->logger, "Couldn't get environment value: name=\"procname\""); goto error; } @@ -201,7 +201,7 @@ static int append_lttng_trace_path_ust_pid(const struct fs_sink_trace *trace, GS v = bt_trace_borrow_environment_entry_value_by_name_const(tc, "vpid"); if (!v || !bt_value_is_signed_integer(v)) { - BT_CPPLOGI_STR_SPEC(trace->logger, "Couldn't get environment value: name=\"vpid\""); + BT_CPPLOGI_SPEC(trace->logger, "Couldn't get environment value: name=\"vpid\""); goto error; } @@ -209,8 +209,7 @@ static int append_lttng_trace_path_ust_pid(const struct fs_sink_trace *trace, GS v = bt_trace_borrow_environment_entry_value_by_name_const(tc, "vpid_datetime"); if (!v || !bt_value_is_string(v)) { - BT_CPPLOGI_STR_SPEC(trace->logger, - "Couldn't get environment value: name=\"vpid_datetime\""); + BT_CPPLOGI_SPEC(trace->logger, "Couldn't get environment value: name=\"vpid_datetime\""); goto error; } @@ -250,7 +249,7 @@ static GString *make_lttng_trace_path_rel(const struct fs_sink_trace *trace) v = bt_trace_borrow_environment_entry_value_by_name_const(trace->ir_trace, "tracer_name"); if (!v || !bt_value_is_string(v)) { - BT_CPPLOGI_STR_SPEC(trace->logger, "Couldn't get environment value: name=\"tracer_name\""); + BT_CPPLOGI_SPEC(trace->logger, "Couldn't get environment value: name=\"tracer_name\""); goto error; } @@ -263,7 +262,7 @@ static GString *make_lttng_trace_path_rel(const struct fs_sink_trace *trace) v = bt_trace_borrow_environment_entry_value_by_name_const(trace->ir_trace, "tracer_major"); if (!v || !bt_value_is_signed_integer(v)) { - BT_CPPLOGI_STR_SPEC(trace->logger, "Couldn't get environment value: name=\"tracer_major\""); + BT_CPPLOGI_SPEC(trace->logger, "Couldn't get environment value: name=\"tracer_major\""); goto error; } @@ -271,7 +270,7 @@ static GString *make_lttng_trace_path_rel(const struct fs_sink_trace *trace) v = bt_trace_borrow_environment_entry_value_by_name_const(trace->ir_trace, "tracer_minor"); if (!v || !bt_value_is_signed_integer(v)) { - BT_CPPLOGI_STR_SPEC(trace->logger, "Couldn't get environment value: name=\"tracer_minor\""); + BT_CPPLOGI_SPEC(trace->logger, "Couldn't get environment value: name=\"tracer_minor\""); goto error; } @@ -286,8 +285,7 @@ static GString *make_lttng_trace_path_rel(const struct fs_sink_trace *trace) v = bt_trace_borrow_environment_entry_value_by_name_const(trace->ir_trace, "hostname"); if (!v || !bt_value_is_string(v)) { - BT_CPPLOGI_STR_SPEC(trace->logger, - "Couldn't get environment value: name=\"tracer_hostname\""); + BT_CPPLOGI_SPEC(trace->logger, "Couldn't get environment value: name=\"tracer_hostname\""); goto error; } @@ -295,7 +293,7 @@ static GString *make_lttng_trace_path_rel(const struct fs_sink_trace *trace) v = bt_trace_borrow_environment_entry_value_by_name_const(trace->ir_trace, "trace_name"); if (!v || !bt_value_is_string(v)) { - BT_CPPLOGI_STR_SPEC(trace->logger, "Couldn't get environment value: name=\"trace_name\""); + BT_CPPLOGI_SPEC(trace->logger, "Couldn't get environment value: name=\"trace_name\""); goto error; } @@ -304,8 +302,8 @@ static GString *make_lttng_trace_path_rel(const struct fs_sink_trace *trace) v = bt_trace_borrow_environment_entry_value_by_name_const(trace->ir_trace, "trace_creation_datetime"); if (!v || !bt_value_is_string(v)) { - BT_CPPLOGI_STR_SPEC(trace->logger, - "Couldn't get environment value: name=\"trace_creation_datetime\""); + BT_CPPLOGI_SPEC(trace->logger, + "Couldn't get environment value: name=\"trace_creation_datetime\""); goto error; } @@ -319,7 +317,7 @@ static GString *make_lttng_trace_path_rel(const struct fs_sink_trace *trace) v = bt_trace_borrow_environment_entry_value_by_name_const(trace->ir_trace, "domain"); if (!v || !bt_value_is_string(v)) { - BT_CPPLOGI_STR_SPEC(trace->logger, "Couldn't get environment value: name=\"domain\""); + BT_CPPLOGI_SPEC(trace->logger, "Couldn't get environment value: name=\"domain\""); goto error; } @@ -332,8 +330,8 @@ static GString *make_lttng_trace_path_rel(const struct fs_sink_trace *trace) v = bt_trace_borrow_environment_entry_value_by_name_const(trace->ir_trace, "tracer_buffering_scheme"); if (!v || !bt_value_is_string(v)) { - BT_CPPLOGI_STR_SPEC(trace->logger, - "Couldn't get environment value: name=\"tracer_buffering_scheme\""); + BT_CPPLOGI_SPEC(trace->logger, + "Couldn't get environment value: name=\"tracer_buffering_scheme\""); goto error; } diff --git a/src/plugins/ctf/fs-sink/fs-sink.cpp b/src/plugins/ctf/fs-sink/fs-sink.cpp index 52d3d426..6b0c88da 100644 --- a/src/plugins/ctf/fs-sink/fs-sink.cpp +++ b/src/plugins/ctf/fs-sink/fs-sink.cpp @@ -965,8 +965,7 @@ bt_component_class_sink_consume_method_status ctf_fs_sink_consume(bt_self_compon break; case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY: /* Ignore */ - BT_CPPLOGD_STR_SPEC(fs_sink->logger, - "Ignoring message iterator inactivity message."); + BT_CPPLOGD_SPEC(fs_sink->logger, "Ignoring message iterator inactivity message."); break; case BT_MESSAGE_TYPE_STREAM_BEGINNING: status = handle_stream_beginning_msg(fs_sink, msg); diff --git a/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.cpp b/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.cpp index 5c8cf801..ca634b95 100644 --- a/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.cpp +++ b/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.cpp @@ -880,13 +880,13 @@ static inline int translate_option_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx append_to_parent_field_class(ctx, &fc->base); ret = cur_path_stack_push(ctx, NULL, false, content_ir_fc, &fc->base); if (ret) { - BT_CPPLOGE_STR_SPEC(ctx->logger, "Cannot translate option field class content."); + BT_CPPLOGE_SPEC(ctx->logger, "Cannot translate option field class content."); goto end; } ret = translate_field_class(ctx); if (ret) { - BT_CPPLOGE_STR_SPEC(ctx->logger, "Cannot translate option field class content."); + BT_CPPLOGE_SPEC(ctx->logger, "Cannot translate option field class content."); goto end; } @@ -1071,13 +1071,13 @@ static inline int translate_static_array_field_class(ctf::sink::TraceIrToCtfIrCt append_to_parent_field_class(ctx, &fc->base.base); ret = cur_path_stack_push(ctx, NULL, false, elem_ir_fc, &fc->base.base); if (ret) { - BT_CPPLOGE_STR_SPEC(ctx->logger, "Cannot translate static array field class element."); + BT_CPPLOGE_SPEC(ctx->logger, "Cannot translate static array field class element."); goto end; } ret = translate_field_class(ctx); if (ret) { - BT_CPPLOGE_STR_SPEC(ctx->logger, "Cannot translate static array field class element."); + BT_CPPLOGE_SPEC(ctx->logger, "Cannot translate static array field class element."); goto end; } @@ -1111,13 +1111,13 @@ static inline int translate_dynamic_array_field_class(ctf::sink::TraceIrToCtfIrC append_to_parent_field_class(ctx, &fc->base.base); ret = cur_path_stack_push(ctx, NULL, false, elem_ir_fc, &fc->base.base); if (ret) { - BT_CPPLOGE_STR_SPEC(ctx->logger, "Cannot translate dynamic array field class element."); + BT_CPPLOGE_SPEC(ctx->logger, "Cannot translate dynamic array field class element."); goto end; } ret = translate_field_class(ctx); if (ret) { - BT_CPPLOGE_STR_SPEC(ctx->logger, "Cannot translate dynamic array field class element."); + BT_CPPLOGE_SPEC(ctx->logger, "Cannot translate dynamic array field class element."); goto end; } diff --git a/src/plugins/ctf/fs-src/data-stream-file.cpp b/src/plugins/ctf/fs-src/data-stream-file.cpp index 22aa309f..d2f7e102 100644 --- a/src/plugins/ctf/fs-src/data-stream-file.cpp +++ b/src/plugins/ctf/fs-src/data-stream-file.cpp @@ -392,8 +392,7 @@ build_index_from_idx_file(struct ctf_fs_ds_file *ds_file, struct ctf_fs_ds_file_ ctf_msg_iter_packet_properties props; int ret = ctf_msg_iter_get_packet_properties(msg_iter, &props); if (ret) { - BT_CPPLOGI_STR_SPEC(ds_file->logger, - "Cannot read first packet's header and context fields."); + BT_CPPLOGI_SPEC(ds_file->logger, "Cannot read first packet's header and context fields."); return bt2s::nullopt; } @@ -401,7 +400,7 @@ build_index_from_idx_file(struct ctf_fs_ds_file *ds_file, struct ctf_fs_ds_file_ ctf_trace_class_borrow_stream_class_by_id(ds_file->metadata->tc, props.stream_class_id); BT_ASSERT(sc); if (!sc->default_clock_class) { - BT_CPPLOGI_STR_SPEC(ds_file->logger, "Cannot find stream class's default clock class."); + BT_CPPLOGI_SPEC(ds_file->logger, "Cannot find stream class's default clock class."); return bt2s::nullopt; } @@ -448,8 +447,8 @@ build_index_from_idx_file(struct ctf_fs_ds_file *ds_file, struct ctf_fs_ds_file_ const char *file_pos = g_mapped_file_get_contents(mapped_file.get()) + sizeof(*header); if (be32toh(header->magic) != CTF_INDEX_MAGIC) { - BT_CPPLOGW_STR_SPEC(ds_file->logger, - "Invalid LTTng trace index: \"magic\" field validation failed"); + BT_CPPLOGW_SPEC(ds_file->logger, + "Invalid LTTng trace index: \"magic\" field validation failed"); return bt2s::nullopt; } @@ -522,7 +521,7 @@ build_index_from_idx_file(struct ctf_fs_ds_file *ds_file, struct ctf_fs_ds_file_ ret = convert_cycles_to_ns(sc->default_clock_class, index_entry.timestamp_begin, &index_entry.timestamp_begin_ns); if (ret) { - BT_CPPLOGI_STR_SPEC( + BT_CPPLOGI_SPEC( ds_file->logger, "Failed to convert raw timestamp to nanoseconds since Epoch during index parsing"); return bt2s::nullopt; @@ -530,7 +529,7 @@ build_index_from_idx_file(struct ctf_fs_ds_file *ds_file, struct ctf_fs_ds_file_ ret = convert_cycles_to_ns(sc->default_clock_class, index_entry.timestamp_end, &index_entry.timestamp_end_ns); if (ret) { - BT_CPPLOGI_STR_SPEC( + BT_CPPLOGI_SPEC( ds_file->logger, "Failed to convert raw timestamp to nanoseconds since Epoch during LTTng trace index parsing"); return bt2s::nullopt; @@ -574,8 +573,8 @@ static int init_index_entry(ctf_fs_ds_index_entry& entry, struct ctf_fs_ds_file int ret = convert_cycles_to_ns(sc->default_clock_class, props->snapshots.beginning_clock, &entry.timestamp_begin_ns); if (ret) { - BT_CPPLOGI_STR_SPEC(ds_file->logger, - "Failed to convert raw timestamp to nanoseconds since Epoch."); + BT_CPPLOGI_SPEC(ds_file->logger, + "Failed to convert raw timestamp to nanoseconds since Epoch."); return ret; } } else { @@ -590,8 +589,8 @@ static int init_index_entry(ctf_fs_ds_index_entry& entry, struct ctf_fs_ds_file int ret = convert_cycles_to_ns(sc->default_clock_class, props->snapshots.end_clock, &entry.timestamp_end_ns); if (ret) { - BT_CPPLOGI_STR_SPEC(ds_file->logger, - "Failed to convert raw timestamp to nanoseconds since Epoch."); + BT_CPPLOGI_SPEC(ds_file->logger, + "Failed to convert raw timestamp to nanoseconds since Epoch."); return ret; } } else { @@ -615,8 +614,8 @@ build_index_from_stream_file(struct ctf_fs_ds_file *ds_file, struct ctf_fs_ds_fi struct ctf_msg_iter_packet_properties props; if (currentPacketOffset.bytes() > ds_file->file->size) { - BT_CPPLOGE_STR_SPEC(ds_file->logger, - "Unexpected current packet's offset (larger than file)."); + BT_CPPLOGE_SPEC(ds_file->logger, + "Unexpected current packet's offset (larger than file)."); return bt2s::nullopt; } else if (currentPacketOffset.bytes() == ds_file->file->size) { /* No more data */ diff --git a/src/plugins/ctf/fs-src/fs.cpp b/src/plugins/ctf/fs-src/fs.cpp index e0f73440..e86d30ce 100644 --- a/src/plugins/ctf/fs-src/fs.cpp +++ b/src/plugins/ctf/fs-src/fs.cpp @@ -406,7 +406,7 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const bt_common_get_page_size(static_cast(ctf_fs_trace->logger.level())) * 8, ctf_fs_ds_file_medops, ds_file.get(), nullptr, ctf_fs_trace->logger); if (!msg_iter) { - BT_CPPLOGE_STR_SPEC(ctf_fs_trace->logger, "Cannot create a CTF message iterator."); + BT_CPPLOGE_SPEC(ctf_fs_trace->logger, "Cannot create a CTF message iterator."); return -1; } @@ -1282,7 +1282,7 @@ static int fix_packet_index_tracer_bugs(ctf_fs_trace *trace) * are needed. Failing to extract these entries is not * an error. */ - BT_CPPLOGI_STR_SPEC( + BT_CPPLOGI_SPEC( trace->logger, "Cannot extract tracer information necessary to compare with buggy versions."); return 0; @@ -1290,9 +1290,8 @@ static int fix_packet_index_tracer_bugs(ctf_fs_trace *trace) /* Check if the trace may be affected by old tracer bugs. */ if (is_tracer_affected_by_lttng_event_after_packet_bug(¤t_tracer_info)) { - BT_CPPLOGI_STR_SPEC( - trace->logger, - "Trace may be affected by LTTng tracer packet timestamp bug. Fixing up."); + BT_CPPLOGI_SPEC(trace->logger, + "Trace may be affected by LTTng tracer packet timestamp bug. Fixing up."); ret = fix_index_lttng_event_after_packet_bug(trace); if (ret) { BT_CPPLOGE_APPEND_CAUSE_SPEC(trace->logger, @@ -1303,9 +1302,8 @@ static int fix_packet_index_tracer_bugs(ctf_fs_trace *trace) } if (is_tracer_affected_by_barectf_event_before_packet_bug(¤t_tracer_info)) { - BT_CPPLOGI_STR_SPEC( - trace->logger, - "Trace may be affected by barectf tracer packet timestamp bug. Fixing up."); + BT_CPPLOGI_SPEC(trace->logger, + "Trace may be affected by barectf tracer packet timestamp bug. Fixing up."); ret = fix_index_barectf_event_before_packet_bug(trace); if (ret) { BT_CPPLOGE_APPEND_CAUSE_SPEC(trace->logger, diff --git a/src/plugins/ctf/lttng-live/lttng-live.cpp b/src/plugins/ctf/lttng-live/lttng-live.cpp index 79fbe550..63681810 100644 --- a/src/plugins/ctf/lttng-live/lttng-live.cpp +++ b/src/plugins/ctf/lttng-live/lttng-live.cpp @@ -1387,7 +1387,7 @@ lttng_live_msg_iter_next(bt_self_message_iterator *self_msg_it, bt_message_array * that of the current candidate message. We * must break the tie in a predictable manner. */ - BT_CPPLOGD_STR_SPEC( + BT_CPPLOGD_SPEC( lttng_live_msg_iter->logger, "Two of the next message candidates have the same timestamps, pick one deterministically."); /* diff --git a/src/plugins/utils/muxer/comp.cpp b/src/plugins/utils/muxer/comp.cpp index ea2df4d0..fb2a1119 100644 --- a/src/plugins/utils/muxer/comp.cpp +++ b/src/plugins/utils/muxer/comp.cpp @@ -13,7 +13,7 @@ namespace bt2mux { Comp::Comp(const bt2::SelfFilterComponent selfComp, const bt2::ConstMapValue params, void *) : bt2::UserFilterComponent {selfComp, "PLUGIN/FLT.UTILS.MUXER"} { - BT_CPPLOGI_STR("Initializing component."); + BT_CPPLOGI("Initializing component."); /* No parameters expected */ if (!params.isEmpty()) { @@ -28,10 +28,10 @@ Comp::Comp(const bt2::SelfFilterComponent selfComp, const bt2::ConstMapValue par try { this->_addOutputPort("out"); } catch (const bt2c::Error&) { - BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW("Failed to add a single output port."); + BT_CPPLOGE_APPEND_CAUSE_AND_RETHROW("Failed to add a single output port."); } - BT_CPPLOGI_STR("Initialized component."); + BT_CPPLOGI("Initialized component."); } void Comp::_inputPortConnected(const bt2::SelfComponentInputPort, const bt2::ConstOutputPort) @@ -44,7 +44,7 @@ void Comp::_addAvailInputPort() try { this->_addInputPort(fmt::format("in{}", this->_inputPorts().length())); } catch (const bt2c::Error&) { - BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW("Failed to add an available input port."); + BT_CPPLOGE_APPEND_CAUSE_AND_RETHROW("Failed to add an available input port."); } BT_CPPLOGI("Added one available input port: name={}", this->_inputPorts().back().name()); diff --git a/src/plugins/utils/muxer/msg-iter.cpp b/src/plugins/utils/muxer/msg-iter.cpp index c3e8c3db..2754bb11 100644 --- a/src/plugins/utils/muxer/msg-iter.cpp +++ b/src/plugins/utils/muxer/msg-iter.cpp @@ -367,18 +367,17 @@ bool MsgIter::_HeapComparator::operator()( * the oldest one, that is, the one having the smallest * timestamp. */ - BT_CPPLOGT_STR("Timestamp of message A is less than timestamp of message B: oldest=A"); + BT_CPPLOGT("Timestamp of message A is less than timestamp of message B: oldest=A"); return true; } else if (*msgTsA > *msgTsB) { - BT_CPPLOGT_STR( - "Timestamp of message A is greater than timestamp of message B: oldest=B"); + BT_CPPLOGT("Timestamp of message A is greater than timestamp of message B: oldest=B"); return false; } } else if (msgTsA && !msgTsB) { - BT_CPPLOGT_STR("Message A has a timestamp, but message B has none: oldest=B"); + BT_CPPLOGT("Message A has a timestamp, but message B has none: oldest=B"); return false; } else if (!msgTsA && msgTsB) { - BT_CPPLOGT_STR("Message B has a timestamp, but message A has none: oldest=A"); + BT_CPPLOGT("Message B has a timestamp, but message A has none: oldest=A"); return true; } -- 2.34.1