2 * SPDX-License-Identifier: MIT
4 * Copyright 2020 Philippe Proulx <pproulx@efficios.com>
7 #define BT_LOG_TAG "LIB/ASSERT-COND"
8 #include "lib/logging.h"
13 #include "common/assert.h"
14 #include "assert-cond-base.h"
17 GString
*format_cond_id(const char *cond_type
, const char *func
,
18 const char *id_suffix
)
20 static const char func_prefix
[] = "bt_";
21 GString
*id
= g_string_new(NULL
);
28 g_string_append_printf(id
, "%s:", cond_type
);
30 /* Function name: no prefix */
32 BT_ASSERT(strstr(func
, func_prefix
) == func
);
33 src_ch
= &func
[strlen(func_prefix
)];
35 /* Function name: `_` replaced with `-` */
36 for (; *src_ch
; src_ch
++) {
45 g_string_append_c(id
, dst_ch
);
50 g_string_append_printf(id
, ":%s", id_suffix
);
55 void bt_lib_assert_cond_failed(const char *cond_type
, const char *func
,
56 const char *id_suffix
, const char *fmt
, ...)
59 GString
*cond_id
= format_cond_id(cond_type
, func
, id_suffix
);
62 BT_ASSERT_COND_MSG("Babeltrace 2 library %scondition not satisfied.",
64 BT_ASSERT_COND_MSG("------------------------------------------------------------------------");
65 BT_ASSERT_COND_MSG("Condition ID: `%s`.", cond_id
->str
);
66 g_string_free(cond_id
, TRUE
);
67 BT_ASSERT_COND_MSG("Function: %s().", func
);
68 BT_ASSERT_COND_MSG("------------------------------------------------------------------------");
69 BT_ASSERT_COND_MSG("Error is:");
71 bt_lib_log_v(__FILE__
, __func__
, __LINE__
, BT_LOG_FATAL
,
72 BT_LOG_TAG
, fmt
, &args
);
74 BT_ASSERT_COND_MSG("Aborting...");
This page took 0.02977 seconds and 4 git commands to generate.