cpp-common/bt2c: fix some function names in comments
[babeltrace.git] / src / cpp-common / bt2c / logging.hpp
CommitLineData
7a72f18a
PP
1/*
2 * SPDX-FileCopyrightText: 2023 Philippe Proulx <pproulx@efficios.com>
3 * SPDX-License-Identifier: MIT
4 */
5
6#ifndef BABELTRACE_CPP_COMMON_BT2C_LOGGING_HPP
7#define BABELTRACE_CPP_COMMON_BT2C_LOGGING_HPP
8
9#include <cstring>
10#include <iterator>
11#include <string>
12#include <utility>
13#include <vector>
14
d88930bc
PP
15#include <glib.h>
16
7a72f18a
PP
17#include <babeltrace2/babeltrace.h>
18
19#include "common/assert.h"
20#include "cpp-common/bt2/private-query-executor.hpp"
21#include "cpp-common/bt2/self-component-class.hpp"
22#include "cpp-common/bt2/self-component-port.hpp"
23#include "cpp-common/bt2/self-message-iterator.hpp"
24#include "cpp-common/bt2s/optional.hpp"
25#include "cpp-common/vendor/fmt/core.h"
26#include "logging/log-api.h"
27
28namespace bt2c {
29
30/*
31 * A logger contains an actor (self component class, self component,
32 * self message iterator, or simple module name), a current logging
33 * level, and a logging tag.
34 *
35 * It offers the logNoThrow(), logMemNoThrow(), logErrnoNoThrow(),
36 * logErrorAndThrow(), logErrorAndRethrow(), logErrorErrnoAndThrow(),
37 * and logErrorErrnoAndRethrow() method templates to log using a given
38 * level, optionally append a cause to the error of the current thread
39 * using the correct actor, and optionally throw or rethrow.
40 *
41 * The methods above expect a format string and zero or more arguments
42 * to be formatted with fmt::format().
43 */
44class Logger final
45{
46public:
47 /* Available log levels */
48 enum class Level
49 {
1c5ea5eb
SM
50 Trace = BT_LOG_TRACE,
51 Debug = BT_LOG_DEBUG,
52 Info = BT_LOG_INFO,
53 Warning = BT_LOG_WARNING,
54 Error = BT_LOG_ERROR,
55 Fatal = BT_LOG_FATAL,
56 None = BT_LOG_NONE,
7a72f18a
PP
57 };
58
59 /*
60 * Builds a logger from the self component class `selfCompCls` using
61 * the tag `tag` and the logging level of `privQueryExec`.
62 */
63 explicit Logger(const bt2::SelfComponentClass selfCompCls,
64 const bt2::PrivateQueryExecutor privQueryExec, std::string tag) noexcept :
65 _mSelfCompCls {selfCompCls},
66 _mLevel {static_cast<Level>(privQueryExec.loggingLevel())}, _mTag {std::move(tag)}
67 {
68 }
69
70 /*
71 * Builds a logger from the self component `selfComp` using the tag
72 * `tag`.
73 */
74 explicit Logger(const bt2::SelfComponent selfComp, std::string tag) noexcept :
75 _mSelfComp {selfComp}, _mLevel {static_cast<Level>(selfComp.loggingLevel())}, _mTag {
76 std::move(
77 tag)}
78 {
79 }
80
81 /*
82 * Builds a logger from the self source component `selfComp` using
83 * the tag `tag`.
84 */
85 explicit Logger(const bt2::SelfSourceComponent selfComp, std::string tag) noexcept :
86 Logger {
87 bt2::SelfComponent {bt_self_component_source_as_self_component(selfComp.libObjPtr())},
88 std::move(tag)}
89 {
90 }
91
92 /*
93 * Builds a logger from the self filter component `selfComp` using
94 * the tag `tag`.
95 */
96 explicit Logger(const bt2::SelfFilterComponent selfComp, std::string tag) noexcept :
97 Logger {
98 bt2::SelfComponent {bt_self_component_filter_as_self_component(selfComp.libObjPtr())},
99 std::move(tag)}
100 {
101 }
102
103 /*
104 * Builds a logger from the self sink component `selfComp` using the
105 * tag `tag`.
106 */
107 explicit Logger(const bt2::SelfSinkComponent selfComp, std::string tag) noexcept :
108 Logger {bt2::SelfComponent {bt_self_component_sink_as_self_component(selfComp.libObjPtr())},
109 std::move(tag)}
110 {
111 }
112
113 /*
114 * Builds a logger from the self message iterator `selfMsgIter`
115 * using the tag `tag`.
116 */
117 explicit Logger(const bt2::SelfMessageIterator selfMsgIter, std::string tag) noexcept :
4f235e19
SM
118 _mSelfMsgIter {selfMsgIter},
119 _mLevel {static_cast<Level>(selfMsgIter.component().loggingLevel())}, _mTag {std::move(tag)}
7a72f18a 120 {
7a72f18a
PP
121 }
122
123 /*
124 * Builds a logger from the module named `moduleName` using the tag
125 * `tag` and logging level `logLevel`.
126 */
127 explicit Logger(std::string moduleName, std::string tag, const Level logLevel) noexcept :
128 _mModuleName {std::move(moduleName)}, _mLevel {logLevel}, _mTag {std::move(tag)}
129 {
130 }
131
132 /*
133 * Builds a logger from another logger `other` using the new tag
134 * `newTag`.
135 */
136 explicit Logger(const Logger& other, std::string newTag) :
eee15e59
SM
137 _mSelfCompCls {other._mSelfCompCls}, _mSelfComp {other._mSelfComp},
138 _mSelfMsgIter {other._mSelfMsgIter},
7a72f18a
PP
139 _mModuleName {other._mModuleName}, _mLevel {other._mLevel}, _mTag {std::move(newTag)}
140 {
141 }
142
143 /*
144 * Current logging level.
145 */
146 Level level() const noexcept
147 {
148 return _mLevel;
149 }
150
151 /*
152 * Current logging level converted to a `bt_log_level` value.
153 *
154 * For legacy code.
155 */
156 bt_log_level cLevel() const noexcept
157 {
158 return static_cast<bt_log_level>(_mLevel);
159 }
160
161 /*
162 * Whether or not this logger would log at the level `level`.
163 */
164 bool wouldLog(const Level level) const noexcept
165 {
166 return BT_LOG_ON_CUR_LVL(static_cast<int>(level), static_cast<int>(_mLevel));
167 }
168
169 /*
170 * Whether or not this logger would log at the trace level.
171 */
172 bool wouldLogT() const noexcept
173 {
1c5ea5eb 174 return this->wouldLog(Level::Trace);
7a72f18a
PP
175 }
176
177 /*
178 * Whether or not this logger would log at the debug level.
179 */
180 bool wouldLogD() const noexcept
181 {
1c5ea5eb 182 return this->wouldLog(Level::Debug);
7a72f18a
PP
183 }
184
185 /*
186 * Whether or not this logger would log at the info level.
187 */
188 bool wouldLogI() const noexcept
189 {
1c5ea5eb 190 return this->wouldLog(Level::Info);
7a72f18a
PP
191 }
192
193 /*
194 * Whether or not this logger would log at the warning level.
195 */
196 bool wouldLogW() const noexcept
197 {
1c5ea5eb 198 return this->wouldLog(Level::Warning);
7a72f18a
PP
199 }
200
201 /*
202 * Whether or not this logger would log at the error level.
203 */
204 bool wouldLogE() const noexcept
205 {
1c5ea5eb 206 return this->wouldLog(Level::Error);
7a72f18a
PP
207 }
208
209 /*
210 * Whether or not this logger would log at the fatal level.
211 */
212 bool wouldLogF() const noexcept
213 {
1c5ea5eb 214 return this->wouldLog(Level::Fatal);
7a72f18a
PP
215 }
216
217 /*
218 * Logging tag.
219 */
220 const std::string& tag() const noexcept
221 {
222 return _mTag;
223 }
224
225 /*
226 * Self component class actor, or `bt2s::nullopt` if none.
227 */
228 const bt2s::optional<bt2::SelfComponentClass>& selfCompCls() const noexcept
229 {
230 return _mSelfCompCls;
231 }
232
233 /*
234 * Self component actor, or `bt2s::nullopt` if none.
235 */
236 const bt2s::optional<bt2::SelfComponent>& selfComp() const noexcept
237 {
238 return _mSelfComp;
239 }
240
241 /*
242 * Self message iterator actor, or `bt2s::nullopt` if none.
243 */
244 const bt2s::optional<bt2::SelfMessageIterator>& selfMsgIter() const noexcept
245 {
246 return _mSelfMsgIter;
247 }
248
249 /*
250 * Name of module actor, or `bt2s::nullopt` if none.
251 */
252 const bt2s::optional<std::string>& moduleName() const noexcept
253 {
254 return _mModuleName;
255 }
256
257private:
258 struct _StdLogWriter final
259 {
260 static void write(const char * const fileName, const char * const funcName,
261 const unsigned lineNo, const Level level, const char * const tag,
d88930bc
PP
262 const void *, unsigned int, const char * const initMsg,
263 const char * const msg) noexcept
7a72f18a 264 {
d88930bc 265 BT_ASSERT_DBG(initMsg && std::strcmp(initMsg, "") == 0);
7a72f18a
PP
266 bt_log_write(fileName, funcName, lineNo, static_cast<bt_log_level>(level), tag, msg);
267 }
268 };
269
270public:
271 /*
272 * Logs using the level `LevelV`.
273 *
274 * This method forwards `fmt` and `args` to fmt::format() to create
275 * the log message.
276 *
277 * If `AppendCauseV` is true, this method also appends a cause to
278 * the error of the current thread using the same message.
279 */
280 template <Level LevelV, bool AppendCauseV, typename... ArgTs>
281 void logNoThrow(const char * const fileName, const char * const funcName,
282 const unsigned int lineNo, const char * const fmt, ArgTs&&...args) const
283 {
284 this->_logNoThrow<_StdLogWriter, LevelV, AppendCauseV>(
d88930bc 285 fileName, funcName, lineNo, nullptr, 0, "", fmt, std::forward<ArgTs>(args)...);
7a72f18a
PP
286 }
287
288 /*
289 * Logs `msg` using the level `LevelV`.
290 *
291 * If `AppendCauseV` is true, this method also appends a cause to
292 * the error of the current thread using the same message.
293 */
294 template <Level LevelV, bool AppendCauseV>
295 void logStrNoThrow(const char * const fileName, const char * const funcName,
296 const unsigned int lineNo, const char * const msg) const
297 {
298 this->_logStrNoThrow<_StdLogWriter, LevelV, AppendCauseV>(fileName, funcName, lineNo,
d88930bc 299 nullptr, 0, "", msg);
7a72f18a
PP
300 }
301
302 /*
65b35e82 303 * Like logNoThrow() with the `Level::Error` level, but also
7a72f18a
PP
304 * throws a default-constructed instance of `ExcT`.
305 */
306 template <bool AppendCauseV, typename ExcT, typename... ArgTs>
307 [[noreturn]] void logErrorAndThrow(const char * const fileName, const char * const funcName,
308 const unsigned int lineNo, const char * const fmt,
309 ArgTs&&...args) const
310 {
1c5ea5eb 311 this->logNoThrow<Level::Error, AppendCauseV>(fileName, funcName, lineNo, fmt,
7a72f18a
PP
312 std::forward<ArgTs>(args)...);
313 throw ExcT {};
314 }
315
316 /*
65b35e82 317 * Like logStrNoThrow() with the `Level::Error` level, but also
7a72f18a
PP
318 * throws a default-constructed instance of `ExcT`.
319 */
320 template <bool AppendCauseV, typename ExcT>
321 [[noreturn]] void logErrorStrAndThrow(const char * const fileName, const char * const funcName,
322 const unsigned int lineNo, const char * const msg) const
323 {
1c5ea5eb 324 this->logStrNoThrow<Level::Error, AppendCauseV>(fileName, funcName, lineNo, msg);
7a72f18a
PP
325 throw ExcT {};
326 }
327
328 /*
65b35e82 329 * Like logNoThrow() with the `Level::Error` level, but also
7a72f18a
PP
330 * rethrows.
331 */
332 template <bool AppendCauseV, typename... ArgTs>
333 [[noreturn]] void logErrorAndRethrow(const char * const fileName, const char * const funcName,
334 const unsigned int lineNo, const char * const fmt,
335 ArgTs&&...args) const
336 {
1c5ea5eb 337 this->logNoThrow<Level::Error, AppendCauseV>(fileName, funcName, lineNo, fmt,
7a72f18a
PP
338 std::forward<ArgTs>(args)...);
339 throw;
340 }
341
342 /*
65b35e82 343 * Like logStrNoThrow() with the `Level::Error` level, but also
7a72f18a
PP
344 * rethrows.
345 */
346 template <bool AppendCauseV>
347 [[noreturn]] void logErrorStrAndRethrow(const char * const fileName,
348 const char * const funcName, const unsigned int lineNo,
349 const char * const msg) const
350 {
1c5ea5eb 351 this->logStrNoThrow<Level::Error, AppendCauseV>(fileName, funcName, lineNo, msg);
7a72f18a
PP
352 throw;
353 }
354
355private:
d88930bc 356 struct _InitMsgLogWriter final
7a72f18a
PP
357 {
358 static void write(const char * const fileName, const char * const funcName,
359 const unsigned lineNo, const Level level, const char * const tag,
360 const void *, unsigned int, const char * const initMsg,
361 const char * const msg) noexcept
362 {
d88930bc
PP
363 bt_log_write_printf(funcName, fileName, lineNo, static_cast<bt_log_level>(level), tag,
364 "%s%s", initMsg, msg);
7a72f18a
PP
365 }
366 };
367
368public:
369 /*
370 * Logs the message of `errno` using the level `LevelV`.
371 *
372 * The log message starts with `initMsg`, is followed with the
373 * message for `errno`, and then with what fmt::format() creates
374 * given `fmt` and `args`.
375 *
376 * If `AppendCauseV` is true, this method also appends a cause to
377 * the error of the current thread using the same message.
378 */
379 template <Level LevelV, bool AppendCauseV, typename... ArgTs>
380 void logErrnoNoThrow(const char * const fileName, const char * const funcName,
381 const unsigned int lineNo, const char * const initMsg,
382 const char * const fmt, ArgTs&&...args) const
383 {
d88930bc
PP
384 this->_logNoThrow<_InitMsgLogWriter, LevelV, AppendCauseV>(
385 fileName, funcName, lineNo, nullptr, 0, this->_errnoIntroStr(initMsg).c_str(), fmt,
386 std::forward<ArgTs>(args)...);
7a72f18a
PP
387 }
388
389 /*
390 * Logs the message of `errno` using the level `LevelV`.
391 *
392 * The log message starts with `initMsg`, is followed with the
393 * message for `errno`, and then with `msg`.
394 *
395 * If `AppendCauseV` is true, this method also appends a cause to
396 * the error of the current thread using the same message.
397 */
398 template <Level LevelV, bool AppendCauseV>
399 void logErrnoStrNoThrow(const char * const fileName, const char * const funcName,
400 const unsigned int lineNo, const char * const initMsg,
401 const char * const msg) const
402 {
d88930bc
PP
403 this->_logStrNoThrow<_InitMsgLogWriter, LevelV, AppendCauseV>(
404 fileName, funcName, lineNo, nullptr, 0, this->_errnoIntroStr(initMsg).c_str(), msg);
7a72f18a
PP
405 }
406
407 /*
1c5ea5eb 408 * Like logErrnoNoThrow() with the `Level::Error` level, but also
7a72f18a
PP
409 * throws a default-constructed instance of `ExcT`.
410 */
411 template <bool AppendCauseV, typename ExcT, typename... ArgTs>
412 [[noreturn]] void logErrorErrnoAndThrow(const char * const fileName,
413 const char * const funcName, const unsigned int lineNo,
414 const char * const initMsg, const char * const fmt,
415 ArgTs&&...args) const
416 {
1c5ea5eb 417 this->logErrnoNoThrow<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg, fmt,
7a72f18a
PP
418 std::forward<ArgTs>(args)...);
419 throw ExcT {};
420 }
421
422 /*
1c5ea5eb 423 * Like logErrnoStrNoThrow() with the `Level::Error` level, but also
7a72f18a
PP
424 * throws a default-constructed instance of `ExcT`.
425 */
426 template <bool AppendCauseV, typename ExcT>
427 [[noreturn]] void
428 logErrorErrnoStrAndThrow(const char * const fileName, const char * const funcName,
429 const unsigned int lineNo, const char * const initMsg,
430 const char * const msg) const
431 {
1c5ea5eb 432 this->logErrnoStrNoThrow<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg,
7a72f18a
PP
433 msg);
434 throw ExcT {};
435 }
436
437 /*
1c5ea5eb 438 * Like logErrnoNoThrow() with the `Level::Error` level, but also
7a72f18a
PP
439 * rethrows.
440 */
441 template <bool AppendCauseV, typename... ArgTs>
442 [[noreturn]] void logErrorErrnoAndRethrow(const char * const fileName,
443 const char * const funcName,
444 const unsigned int lineNo, const char * const initMsg,
445 const char * const fmt, ArgTs&&...args) const
446 {
1c5ea5eb 447 this->logErrnoNoThrow<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg, fmt,
7a72f18a
PP
448 std::forward<ArgTs>(args)...);
449 throw;
450 }
451
452 /*
1c5ea5eb 453 * Like logErrnoStrNoThrow() with the `Level::Error` level, but also
7a72f18a
PP
454 * rethrows.
455 */
456 template <bool AppendCauseV>
457 [[noreturn]] void
458 logErrorErrnoStrAndRethrow(const char * const fileName, const char * const funcName,
459 const unsigned int lineNo, const char * const initMsg,
460 const char * const msg) const
461 {
1c5ea5eb 462 this->logErrnoStrNoThrow<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg,
7a72f18a
PP
463 msg);
464 throw;
465 }
466
467private:
468 struct _MemLogWriter final
469 {
470 static void write(const char * const fileName, const char * const funcName,
471 const unsigned lineNo, const Level level, const char * const tag,
472 const void * const memData, const unsigned int memLen, const char *,
473 const char * const msg) noexcept
474 {
475 bt_log_write_mem(funcName, fileName, lineNo, static_cast<bt_log_level>(level), tag,
476 memData, memLen, msg);
477 }
478 };
479
480public:
481 /*
482 * Logs memory data using the level `LevelV`.
483 *
484 * This method forwards `fmt` and `args` to fmt::format() to create
485 * the log message.
486 */
487 template <Level LevelV, typename... ArgTs>
488 void logMemNoThrow(const char * const fileName, const char * const funcName,
489 const unsigned int lineNo, const void * const memData,
490 const unsigned int memLen, const char * const fmt, ArgTs&&...args) const
491 {
492 this->_logNoThrow<_MemLogWriter, LevelV, false>(fileName, funcName, lineNo, memData, memLen,
d88930bc 493 "", fmt, std::forward<ArgTs>(args)...);
7a72f18a
PP
494 }
495
496 /*
497 * Logs memory data using the level `LevelV`, starting with the
498 * message `msg`.
499 */
500 template <Level LevelV>
501 void logMemStrNoThrow(const char * const fileName, const char * const funcName,
502 const unsigned int lineNo, const void * const memData,
503 const unsigned int memLen, const char * const msg) const
504 {
505 this->_logStrNoThrow<_MemLogWriter, LevelV, false>(fileName, funcName, lineNo, memData,
d88930bc 506 memLen, "", msg);
7a72f18a
PP
507 }
508
509private:
510 /*
511 * Formats a log message with fmt::format() given `fmt` and `args`,
d88930bc 512 * and then forwards everything to _logStrNoThrow().
7a72f18a
PP
513 */
514 template <typename LogWriterT, Level LevelV, bool AppendCauseV, typename... ArgTs>
515 void _logNoThrow(const char * const fileName, const char * const funcName,
516 const unsigned int lineNo, const void * const memData,
517 const std::size_t memLen, const char * const initMsg, const char * const fmt,
518 ArgTs&&...args) const
519 {
520 /* Only format arguments if logging or appending an error cause */
521 if (G_UNLIKELY(this->wouldLog(LevelV) || AppendCauseV)) {
522 /*
523 * Format arguments to our buffer (fmt::format_to() doesn't
524 * append a null character).
525 */
526 _mBuf.clear();
527 fmt::format_to(std::back_inserter(_mBuf), fmt, std::forward<ArgTs>(args)...);
528 _mBuf.push_back('\0');
529 }
530
531 this->_logStrNoThrow<LogWriterT, LevelV, AppendCauseV>(fileName, funcName, lineNo, memData,
532 memLen, initMsg, _mBuf.data());
533 }
534
535 /*
d88930bc
PP
536 * Calls LogWriterT::write() with its arguments to log using the
537 * level `LevelV`.
7a72f18a
PP
538 *
539 * If `AppendCauseV` is true, this method also appends a cause to
d88930bc
PP
540 * the error of the current thread using the concatenation of
541 * `initMsg` and `msg` as the message.
7a72f18a
PP
542 */
543 template <typename LogWriterT, Level LevelV, bool AppendCauseV>
544 void _logStrNoThrow(const char * const fileName, const char * const funcName,
545 const unsigned int lineNo, const void * const memData,
546 const std::size_t memLen, const char * const initMsg,
547 const char * const msg) const
548 {
d88930bc
PP
549 /* Initial message and main message are required */
550 BT_ASSERT(initMsg);
551 BT_ASSERT(msg);
552
7a72f18a
PP
553 /* Log if needed */
554 if (this->wouldLog(LevelV)) {
555 LogWriterT::write(fileName, funcName, lineNo, LevelV, _mTag.data(), memData, memLen,
556 initMsg, msg);
557 }
558
559 /* Append an error cause if needed */
560 if (AppendCauseV) {
561 if (_mSelfMsgIter) {
562 bt_current_thread_error_append_cause_from_message_iterator(
bdc900ed 563 _mSelfMsgIter->libObjPtr(), fileName, lineNo, "%s%s", initMsg, msg);
7a72f18a
PP
564 } else if (_mSelfComp) {
565 bt_current_thread_error_append_cause_from_component(
bdc900ed 566 _mSelfComp->libObjPtr(), fileName, lineNo, "%s%s", initMsg, msg);
7a72f18a
PP
567 } else if (_mSelfCompCls) {
568 bt_current_thread_error_append_cause_from_component_class(
bdc900ed 569 _mSelfCompCls->libObjPtr(), fileName, lineNo, "%s%s", initMsg, msg);
7a72f18a 570 } else {
d88930bc 571 BT_ASSERT(_mModuleName);
bdc900ed
PP
572 bt_current_thread_error_append_cause_from_unknown(_mModuleName->data(), fileName,
573 lineNo, "%s%s", initMsg, msg);
7a72f18a
PP
574 }
575 }
576 }
577
d88930bc
PP
578 static std::string _errnoIntroStr(const char * const initMsg)
579 {
580 BT_ASSERT(errno != 0);
581 return fmt::format("{}: {}", initMsg, g_strerror(errno));
582 }
583
4f235e19 584 /* Exactly one of the following four members has a value */
7a72f18a
PP
585 bt2s::optional<bt2::SelfComponentClass> _mSelfCompCls;
586 bt2s::optional<bt2::SelfComponent> _mSelfComp;
587 bt2s::optional<bt2::SelfMessageIterator> _mSelfMsgIter;
588 bt2s::optional<std::string> _mModuleName;
589
590 /* Current logging level */
591 Level _mLevel;
592
593 /* Logging tag */
594 std::string _mTag;
595
596 /* Formatting buffer */
597 mutable std::vector<char> _mBuf;
598};
599
600} /* namespace bt2c */
601
602/* Internal: default logger name */
603#define _BT_CPPLOG_DEF_LOGGER _mLogger
604
605/*
606 * Calls logNoThrow() on `_logger` to log using the level `_lvl` without
607 * appending nor throwing.
608 */
609#define BT_CPPLOG_EX(_lvl, _logger, _fmt, ...) \
610 do { \
611 if (G_UNLIKELY((_logger).wouldLog(_lvl))) { \
612 (_logger).logNoThrow<(_lvl), false>(__FILE__, __func__, __LINE__, (_fmt), \
613 ##__VA_ARGS__); \
614 } \
615 } while (0)
616
617/*
618 * BT_CPPLOG_EX() with specific logging levels.
619 */
620#define BT_CPPLOGT_SPEC(_logger, _fmt, ...) \
1c5ea5eb 621 BT_CPPLOG_EX(bt2c::Logger::Level::Trace, (_logger), (_fmt), ##__VA_ARGS__)
7a72f18a 622#define BT_CPPLOGD_SPEC(_logger, _fmt, ...) \
1c5ea5eb 623 BT_CPPLOG_EX(bt2c::Logger::Level::Debug, (_logger), (_fmt), ##__VA_ARGS__)
7a72f18a 624#define BT_CPPLOGI_SPEC(_logger, _fmt, ...) \
1c5ea5eb 625 BT_CPPLOG_EX(bt2c::Logger::Level::Info, (_logger), (_fmt), ##__VA_ARGS__)
7a72f18a 626#define BT_CPPLOGW_SPEC(_logger, _fmt, ...) \
1c5ea5eb 627 BT_CPPLOG_EX(bt2c::Logger::Level::Warning, (_logger), (_fmt), ##__VA_ARGS__)
7a72f18a 628#define BT_CPPLOGE_SPEC(_logger, _fmt, ...) \
1c5ea5eb 629 BT_CPPLOG_EX(bt2c::Logger::Level::Error, (_logger), (_fmt), ##__VA_ARGS__)
7a72f18a 630#define BT_CPPLOGF_SPEC(_logger, _fmt, ...) \
1c5ea5eb 631 BT_CPPLOG_EX(bt2c::Logger::Level::Fatal, (_logger), (_fmt), ##__VA_ARGS__)
7a72f18a
PP
632
633/*
634 * BT_CPPLOG_EX() with specific logging levels and using the default
635 * logger.
636 */
637#define BT_CPPLOGT(_fmt, ...) BT_CPPLOGT_SPEC(_BT_CPPLOG_DEF_LOGGER, (_fmt), ##__VA_ARGS__)
638#define BT_CPPLOGD(_fmt, ...) BT_CPPLOGD_SPEC(_BT_CPPLOG_DEF_LOGGER, (_fmt), ##__VA_ARGS__)
639#define BT_CPPLOGI(_fmt, ...) BT_CPPLOGI_SPEC(_BT_CPPLOG_DEF_LOGGER, (_fmt), ##__VA_ARGS__)
640#define BT_CPPLOGW(_fmt, ...) BT_CPPLOGW_SPEC(_BT_CPPLOG_DEF_LOGGER, (_fmt), ##__VA_ARGS__)
641#define BT_CPPLOGE(_fmt, ...) BT_CPPLOGE_SPEC(_BT_CPPLOG_DEF_LOGGER, (_fmt), ##__VA_ARGS__)
642#define BT_CPPLOGF(_fmt, ...) BT_CPPLOGF_SPEC(_BT_CPPLOG_DEF_LOGGER, (_fmt), ##__VA_ARGS__)
643
644/*
645 * Calls logStrNoThrow() on `_logger` to log using the level `_lvl`
646 * without appending nor throwing.
647 */
648#define BT_CPPLOG_STR_EX(_lvl, _logger, _msg) \
649 (_logger).logStrNoThrow<(_lvl), false>(__FILE__, __func__, __LINE__, (_msg))
650
651/*
652 * BT_CPPLOG_STR_EX() with specific logging levels.
653 */
654#define BT_CPPLOGT_STR_SPEC(_logger, _msg) \
1c5ea5eb 655 BT_CPPLOG_STR_EX(bt2c::Logger::Level::Trace, (_logger), (_msg))
7a72f18a 656#define BT_CPPLOGD_STR_SPEC(_logger, _msg) \
1c5ea5eb 657 BT_CPPLOG_STR_EX(bt2c::Logger::Level::Debug, (_logger), (_msg))
7a72f18a 658#define BT_CPPLOGI_STR_SPEC(_logger, _msg) \
1c5ea5eb 659 BT_CPPLOG_STR_EX(bt2c::Logger::Level::Info, (_logger), (_msg))
7a72f18a 660#define BT_CPPLOGW_STR_SPEC(_logger, _msg) \
1c5ea5eb 661 BT_CPPLOG_STR_EX(bt2c::Logger::Level::Warning, (_logger), (_msg))
7a72f18a 662#define BT_CPPLOGE_STR_SPEC(_logger, _msg) \
1c5ea5eb 663 BT_CPPLOG_STR_EX(bt2c::Logger::Level::Error, (_logger), (_msg))
7a72f18a 664#define BT_CPPLOGF_STR_SPEC(_logger, _msg) \
1c5ea5eb 665 BT_CPPLOG_STR_EX(bt2c::Logger::Level::Fatal, (_logger), (_msg))
7a72f18a
PP
666
667/*
668 * BT_CPPLOG_STR_EX() with specific logging levels and using the default
669 * logger.
670 */
671#define BT_CPPLOGT_STR(_msg) BT_CPPLOGT_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg))
672#define BT_CPPLOGD_STR(_msg) BT_CPPLOGD_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg))
673#define BT_CPPLOGI_STR(_msg) BT_CPPLOGI_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg))
674#define BT_CPPLOGW_STR(_msg) BT_CPPLOGW_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg))
675#define BT_CPPLOGE_STR(_msg) BT_CPPLOGE_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg))
676#define BT_CPPLOGF_STR(_msg) BT_CPPLOGF_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg))
677
678/*
679 * Calls logMemNoThrow() on `_logger` to log using the level `_lvl`
680 * without appending nor throwing.
681 */
682#define BT_CPPLOG_MEM_EX(_lvl, _logger, _mem_data, _mem_len, _fmt, ...) \
683 do { \
684 if (G_UNLIKELY((_logger).wouldLog(_lvl))) { \
685 (_logger).logMemNoThrow<(_lvl)>(__FILE__, __func__, __LINE__, (_mem_data), (_mem_len), \
686 (_fmt), ##__VA_ARGS__); \
687 } \
688 } while (0)
689
690/*
691 * BT_CPPLOG_MEM_EX() with specific logging levels.
692 */
693#define BT_CPPLOGT_MEM_SPEC(_logger, _mem_data, _mem_len, _fmt, ...) \
1c5ea5eb 694 BT_CPPLOG_MEM_EX(bt2c::Logger::Level::Trace, (_logger), (_mem_data), (_mem_len), (_fmt), \
7a72f18a
PP
695 ##__VA_ARGS__)
696#define BT_CPPLOGD_MEM_SPEC(_logger, _mem_data, _mem_len, _fmt, ...) \
1c5ea5eb 697 BT_CPPLOG_MEM_EX(bt2c::Logger::Level::Debug, (_logger), (_mem_data), (_mem_len), (_fmt), \
7a72f18a
PP
698 ##__VA_ARGS__)
699#define BT_CPPLOGI_MEM_SPEC(_logger, _mem_data, _mem_len, _fmt, ...) \
1c5ea5eb 700 BT_CPPLOG_MEM_EX(bt2c::Logger::Level::Info, (_logger), (_mem_data), (_mem_len), (_fmt), \
7a72f18a
PP
701 ##__VA_ARGS__)
702#define BT_CPPLOGW_MEM_SPEC(_logger, _mem_data, _mem_len, _fmt, ...) \
1c5ea5eb 703 BT_CPPLOG_MEM_EX(bt2c::Logger::Level::Warning, (_logger), (_mem_data), (_mem_len), (_fmt), \
7a72f18a
PP
704 ##__VA_ARGS__)
705#define BT_CPPLOGE_MEM_SPEC(_logger, _mem_data, _mem_len, _fmt, ...) \
1c5ea5eb 706 BT_CPPLOG_MEM_EX(bt2c::Logger::Level::Error, (_logger), (_mem_data), (_mem_len), (_fmt), \
7a72f18a
PP
707 ##__VA_ARGS__)
708#define BT_CPPLOGF_MEM_SPEC(_logger, _mem_data, _mem_len, _fmt, ...) \
1c5ea5eb 709 BT_CPPLOG_MEM_EX(bt2c::Logger::Level::Fatal, (_logger), (_mem_data), (_mem_len), (_fmt), \
7a72f18a
PP
710 ##__VA_ARGS__)
711
712/*
713 * BT_CPPLOG_MEM_EX() with specific logging levels and using the default
714 * logger.
715 */
716#define BT_CPPLOGT_MEM(_mem_data, _mem_len, _fmt, ...) \
717 BT_CPPLOGT_MEM_SPEC(_BT_CPPLOG_DEF_LOGGER, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
718#define BT_CPPLOGD_MEM(_mem_data, _mem_len, _fmt, ...) \
719 BT_CPPLOGD_MEM_SPEC(_BT_CPPLOG_DEF_LOGGER, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
720#define BT_CPPLOGI_MEM(_mem_data, _mem_len, _fmt, ...) \
721 BT_CPPLOGI_MEM_SPEC(_BT_CPPLOG_DEF_LOGGER, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
722#define BT_CPPLOGW_MEM(_mem_data, _mem_len, _fmt, ...) \
723 BT_CPPLOGW_MEM_SPEC(_BT_CPPLOG_DEF_LOGGER, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
724#define BT_CPPLOGE_MEM(_mem_data, _mem_len, _fmt, ...) \
725 BT_CPPLOGE_MEM_SPEC(_BT_CPPLOG_DEF_LOGGER, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
726#define BT_CPPLOGF_MEM(_mem_data, _mem_len, _fmt, ...) \
727 BT_CPPLOGF_MEM_SPEC(_BT_CPPLOG_DEF_LOGGER, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
728
729/*
730 * Calls logMemStrNoThrow() on `_logger` to log using the level `_lvl`
731 * without appending nor throwing.
732 */
733#define BT_CPPLOG_MEM_STR_EX(_lvl, _logger, _mem_data, _mem_len, _msg) \
734 (_logger).logMemStrNoThrow<(_lvl)>(__FILE__, __func__, __LINE__, (_mem_data), (_mem_len), \
735 (_msg))
736
737/*
738 * BT_CPPLOG_MEM_STR_EX() with specific logging levels.
739 */
740#define BT_CPPLOGT_MEM_STR_SPEC(_logger, _mem_data, _mem_len, _msg) \
741 BT_CPPLOG_MEM_STR_EX(bt2c::Logger::Level::TRACE, (_logger), (_mem_data), (_mem_len), (_msg))
742#define BT_CPPLOGD_MEM_STR_SPEC(_logger, _mem_data, _mem_len, _msg) \
743 BT_CPPLOG_MEM_STR_EX(bt2c::Logger::Level::DEBUG, (_logger), (_mem_data), (_mem_len), (_msg))
744#define BT_CPPLOGI_MEM_STR_SPEC(_logger, _mem_data, _mem_len, _msg) \
745 BT_CPPLOG_MEM_STR_EX(bt2c::Logger::Level::INFO, (_logger), (_mem_data), (_mem_len), (_msg))
746#define BT_CPPLOGW_MEM_STR_SPEC(_logger, _mem_data, _mem_len, _msg) \
747 BT_CPPLOG_MEM_STR_EX(bt2c::Logger::Level::WARNING, (_logger), (_mem_data), (_mem_len), (_msg))
748#define BT_CPPLOGE_MEM_STR_SPEC(_logger, _mem_data, _mem_len, _msg) \
1c5ea5eb 749 BT_CPPLOG_MEM_STR_EX(bt2c::Logger::Level::Error, (_logger), (_mem_data), (_mem_len), (_msg))
7a72f18a
PP
750#define BT_CPPLOGF_MEM_STR_SPEC(_logger, _mem_data, _mem_len, _msg) \
751 BT_CPPLOG_MEM_STR_EX(bt2c::Logger::Level::FATAL, (_logger), (_mem_data), (_mem_len), (_msg))
752
753/*
754 * BT_CPPLOG_MEM_STR_EX() with specific logging levels and using the
755 * default logger.
756 */
757#define BT_CPPLOGT_MEM_STR(_mem_data, _mem_len, _msg) \
758 BT_CPPLOGT_MEM_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_mem_data), (_mem_len), (_msg))
759#define BT_CPPLOGD_MEM_STR(_mem_data, _mem_len, _msg) \
760 BT_CPPLOGD_MEM_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_mem_data), (_mem_len), (_msg))
761#define BT_CPPLOGI_MEM_STR(_mem_data, _mem_len, _msg) \
762 BT_CPPLOGI_MEM_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_mem_data), (_mem_len), (_msg))
763#define BT_CPPLOGW_MEM_STR(_mem_data, _mem_len, _msg) \
764 BT_CPPLOGW_MEM_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_mem_data), (_mem_len), (_msg))
765#define BT_CPPLOGE_MEM_STR(_mem_data, _mem_len, _msg) \
766 BT_CPPLOGE_MEM_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_mem_data), (_mem_len), (_msg))
767#define BT_CPPLOGF_MEM_STR(_mem_data, _mem_len, _msg) \
768 BT_CPPLOGF_MEM_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_mem_data), (_mem_len), (_msg))
769
770/*
771 * Calls logErrnoNoThrow() on `_logger` to log using the level `_lvl`
772 * and initial message `_init_msg` without appending nor throwing.
773 */
774#define BT_CPPLOG_ERRNO_EX(_lvl, _logger, _init_msg, _fmt, ...) \
775 do { \
776 if (G_UNLIKELY((_logger).wouldLog(_lvl))) { \
777 (_logger).logErrnoNoThrow<(_lvl), false>(__FILE__, __func__, __LINE__, (_init_msg), \
778 (_fmt), ##__VA_ARGS__); \
779 } \
780 } while (0)
781
782/*
783 * BT_CPPLOG_ERRNO_EX() with specific logging levels.
784 */
785#define BT_CPPLOGT_ERRNO_SPEC(_logger, _init_msg, _fmt, ...) \
1c5ea5eb 786 BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::Trace, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
7a72f18a 787#define BT_CPPLOGD_ERRNO_SPEC(_logger, _init_msg, _fmt, ...) \
1c5ea5eb 788 BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::Debug, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
7a72f18a 789#define BT_CPPLOGI_ERRNO_SPEC(_logger, _init_msg, _fmt, ...) \
1c5ea5eb 790 BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::Info, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
7a72f18a 791#define BT_CPPLOGW_ERRNO_SPEC(_logger, _init_msg, _fmt, ...) \
1c5ea5eb 792 BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::Warning, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
7a72f18a 793#define BT_CPPLOGE_ERRNO_SPEC(_logger, _init_msg, _fmt, ...) \
1c5ea5eb 794 BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::Error, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
7a72f18a 795#define BT_CPPLOGF_ERRNO_SPEC(_logger, _init_msg, _fmt, ...) \
1c5ea5eb 796 BT_CPPLOG_ERRNO_EX(bt2c::Logger::Level::Fatal, (_logger), (_init_msg), (_fmt), ##__VA_ARGS__)
7a72f18a
PP
797
798/*
799 * BT_CPPLOG_ERRNO_EX() with specific logging levels and using the
800 * default logger.
801 */
802#define BT_CPPLOGT_ERRNO(_init_msg, _fmt, ...) \
803 BT_CPPLOGT_ERRNO_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_fmt), ##__VA_ARGS__)
804#define BT_CPPLOGD_ERRNO(_init_msg, _fmt, ...) \
805 BT_CPPLOGD_ERRNO_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_fmt), ##__VA_ARGS__)
806#define BT_CPPLOGI_ERRNO(_init_msg, _fmt, ...) \
807 BT_CPPLOGI_ERRNO_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_fmt), ##__VA_ARGS__)
808#define BT_CPPLOGW_ERRNO(_init_msg, _fmt, ...) \
809 BT_CPPLOGW_ERRNO_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_fmt), ##__VA_ARGS__)
810#define BT_CPPLOGE_ERRNO(_init_msg, _fmt, ...) \
811 BT_CPPLOGE_ERRNO_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_fmt), ##__VA_ARGS__)
812#define BT_CPPLOGF_ERRNO(_init_msg, _fmt, ...) \
813 BT_CPPLOGF_ERRNO_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_fmt), ##__VA_ARGS__)
814
815/*
816 * Calls logErrnoStrNoThrow() on `_logger` to log using the level `_lvl`
817 * and initial message `_init_msg` without appending nor throwing.
818 */
819#define BT_CPPLOG_ERRNO_STR_EX(_lvl, _logger, _init_msg, _msg) \
820 (_logger).logErrnoStrNoThrow<(_lvl), false>(__FILE__, __func__, __LINE__, (_init_msg), (_msg))
821
822/*
823 * BT_CPPLOG_ERRNO_STR_EX() with specific logging levels.
824 */
825#define BT_CPPLOGT_ERRNO_STR_SPEC(_logger, _init_msg, _msg) \
1c5ea5eb 826 BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Trace, (_logger), (_init_msg), (_msg))
7a72f18a 827#define BT_CPPLOGD_ERRNO_STR_SPEC(_logger, _init_msg, _msg) \
1c5ea5eb 828 BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Debug, (_logger), (_init_msg), (_msg))
7a72f18a 829#define BT_CPPLOGI_ERRNO_STR_SPEC(_logger, _init_msg, _msg) \
1c5ea5eb 830 BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Info, (_logger), (_init_msg), (_msg))
7a72f18a 831#define BT_CPPLOGW_ERRNO_STR_SPEC(_logger, _init_msg, _msg) \
1c5ea5eb 832 BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Warning, (_logger), (_init_msg), (_msg))
7a72f18a 833#define BT_CPPLOGE_ERRNO_STR_SPEC(_logger, _init_msg, _msg) \
1c5ea5eb 834 BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Error, (_logger), (_init_msg), (_msg))
7a72f18a 835#define BT_CPPLOGF_ERRNO_STR_SPEC(_logger, _init_msg, _msg) \
1c5ea5eb 836 BT_CPPLOG_ERRNO_STR_EX(bt2c::Logger::Level::Fatal, (_logger), (_init_msg), (_msg))
7a72f18a
PP
837
838/*
839 * BT_CPPLOG_ERRNO_STR_EX() with specific logging levels and using the
840 * default logger.
841 */
842#define BT_CPPLOGT_ERRNO_STR(_init_msg, _msg) \
843 BT_CPPLOGT_ERRNO_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_msg))
844#define BT_CPPLOGD_ERRNO_STR(_init_msg, _msg) \
845 BT_CPPLOGD_ERRNO_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_msg))
846#define BT_CPPLOGI_ERRNO_STR(_init_msg, _msg) \
847 BT_CPPLOGI_ERRNO_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_msg))
848#define BT_CPPLOGW_ERRNO_STR(_init_msg, _msg) \
849 BT_CPPLOGW_ERRNO_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_msg))
850#define BT_CPPLOGE_ERRNO_STR(_init_msg, _msg) \
851 BT_CPPLOGE_ERRNO_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_msg))
852#define BT_CPPLOGF_ERRNO_STR(_init_msg, _msg) \
853 BT_CPPLOGF_ERRNO_STR_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_msg))
854
855/*
856 * Calls logErrorAndThrow() on `_logger` to log an error, append a cause
857 * to the error of the current thread, and throw an instance of
858 * `_exc_cls`.
859 */
860#define BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(_logger, _exc_cls, _fmt, ...) \
861 (_logger).logErrorAndThrow<true, _exc_cls>(__FILE__, __func__, __LINE__, (_fmt), ##__VA_ARGS__)
862
7a72f18a
PP
863/*
864 * BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC() using the default logger.
865 */
866#define BT_CPPLOGE_APPEND_CAUSE_AND_THROW(_exc_cls, _fmt, ...) \
867 BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(_BT_CPPLOG_DEF_LOGGER, _exc_cls, (_fmt), ##__VA_ARGS__)
868
869/*
870 * Calls logErrorStrAndThrow() on `_logger` to log an error, append a
871 * cause to the error of the current thread, and throw an instance of
872 * `_exc_cls`.
873 */
874#define BT_CPPLOGE_STR_APPEND_CAUSE_AND_THROW_SPEC(_logger, _exc_cls, _msg) \
875 (_logger).logErrorStrAndThrow<true, _exc_cls>(__FILE__, __func__, __LINE__, (_msg))
876
877/*
878 * BT_CPPLOGE_STR_APPEND_CAUSE_AND_THROW_SPEC() using the default
879 * logger.
880 */
881#define BT_CPPLOGE_STR_APPEND_CAUSE_AND_THROW(_exc_cls, _msg) \
882 BT_CPPLOGE_STR_APPEND_CAUSE_AND_THROW_SPEC(_BT_CPPLOG_DEF_LOGGER, _exc_cls, (_msg))
883
884/*
885 * Calls logErrorAndRethrow() on `_logger` to log an error, append a
886 * cause to the error of the current thread, and throw an instance of
887 * `_exc_cls`.
888 */
889#define BT_CPPLOGE_APPEND_CAUSE_AND_RETHROW_SPEC(_logger, _fmt, ...) \
890 (_logger).logErrorAndRethrow<true>(__FILE__, __func__, __LINE__, (_fmt), ##__VA_ARGS__)
891
892/*
893 * BT_CPPLOGE_APPEND_CAUSE_AND_RETHROW_SPEC() using the default logger.
894 */
895#define BT_CPPLOGE_APPEND_CAUSE_AND_RETHROW(_fmt, ...) \
896 BT_CPPLOGE_APPEND_CAUSE_AND_RETHROW_SPEC(_BT_CPPLOG_DEF_LOGGER, (_fmt), ##__VA_ARGS__)
897
898/*
899 * Calls logErrorStrAndRethrow() on `_logger` to log an error, append a
900 * cause to the error of the current thread, and throw an instance of
901 * `_exc_cls`.
902 */
903#define BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW_SPEC(_logger, _msg) \
904 (_logger).logErrorStrAndRethrow<true>(__FILE__, __func__, __LINE__, (_msg))
905
906/*
907 * BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW_SPEC() using the default
908 * logger.
909 */
910#define BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW(_msg) \
911 BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg))
912
913/*
914 * Calls logErrorErrnoAndThrow() on `_logger` to log an error, append a
915 * cause to the error of the current thread, and throw an instance of
916 * `_exc_cls`.
917 */
918#define BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_THROW_SPEC(_logger, _exc_cls, _init_msg, _fmt, ...) \
919 (_logger).logErrorErrnoAndThrow<true, _exc_cls>(__FILE__, __func__, __LINE__, (_init_msg), \
920 (_fmt), ##__VA_ARGS__)
921
922/*
923 * BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_THROW_SPEC() using the default
924 * logger.
925 */
926#define BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_THROW(_exc_cls, _init_msg, _fmt, ...) \
927 BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_THROW_SPEC(_BT_CPPLOG_DEF_LOGGER, _exc_cls, (_init_msg), \
928 (_fmt), ##__VA_ARGS__)
929
930/*
931 * Calls logErrorErrnoStrAndThrow() on `_logger` to log an error, append
932 * a cause to the error of the current thread, and throw an instance of
933 * `_exc_cls`.
934 */
935#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_THROW_SPEC(_logger, _exc_cls, _init_msg, _msg) \
936 (_logger).logErrorErrnoStrAndThrow<true, _exc_cls>(__FILE__, __func__, __LINE__, (_init_msg), \
937 (_msg))
938
939/*
940 * BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_THROW_SPEC() using the default
941 * logger.
942 */
943#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_THROW(_exc_cls, _init_msg, _msg) \
944 BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_THROW_SPEC(_BT_CPPLOG_DEF_LOGGER, _exc_cls, (_init_msg), \
945 (_msg))
946
947/*
948 * Calls logErrorErrnoAndRethrow() on `_logger` to log an error, append
949 * a cause to the error of the current thread, and throw an instance of
950 * `_exc_cls`.
951 */
952#define BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_RETHROW_SPEC(_logger, _init_msg, _fmt, ...) \
953 (_logger).logErrorErrnoAndRethrow<true>(__FILE__, __func__, __LINE__, (_init_msg), (_fmt), \
954 ##__VA_ARGS__)
955
956/*
957 * BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_RETHROW_SPEC() using the default
958 * logger.
959 */
960#define BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_RETHROW(_init_msg, _fmt, ...) \
961 BT_CPPLOGE_ERRNO_APPEND_CAUSE_AND_RETHROW_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_fmt), \
962 ##__VA_ARGS__)
963
964/*
965 * Calls logErrorErrnoStrAndRethrow() on `_logger` to log an error,
966 * append a cause to the error of the current thread, and throw an
967 * instance of `_exc_cls`.
968 */
969#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_RETHROW_SPEC(_logger, _init_msg, _msg) \
970 (_logger).logErrorErrnoStrAndRethrow<true>(__FILE__, __func__, __LINE__, (_init_msg), (_msg))
971
972/*
973 * BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_RETHROW_SPEC() using the
974 * default logger.
975 */
976#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_RETHROW(_init_msg, _msg) \
977 BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_AND_RETHROW_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_msg))
978
979#endif /* BABELTRACE_CPP_COMMON_BT2C_LOGGING_HPP */
This page took 0.066354 seconds and 4 git commands to generate.