#include <stdio.h> /* snprintf */
#include <stdlib.h> /* snprintf */
-#include "src/portable.h" /* to get a working stdarg.h */
+#include "src/internal_config.h"
#include "src/xbt_modinter.h"
#include "xbt/xbt_os_thread.h"
int xbt_log_no_loc = 0; /* if set to true (with --log=no_loc), file localization will be omitted (for tesh tests) */
-static xbt_os_rmutex_t log_cat_init_mutex = NULL;
+static xbt_os_mutex_t log_cat_init_mutex = NULL;
/** \addtogroup XBT_log
*
- %%l: location where the log event was raised (LOG4J compatible, like '%%F:%%L' -- this is a l as in 'l'etter)
- %%L: line number where the log event was raised (LOG4J compatible)
- %%M: function name (LOG4J compatible -- called method name here of course).
- Defined only when using gcc because there is no __FUNCTION__ elsewhere.
- %%b: full backtrace (Called %%throwable in LOG4J).
Defined only under windows or when using the GNU libc because backtrace() is not defined
structure which starts with a pointer to a do_append() function. do_append()
prints a message to a log.
-When a category is passed a message by one of the logging macros, the
-category performs the following actions:
+When a category is passed a message by one of the logging macros, the category performs the following actions:
- if the category has an appender, the message is passed to the
appender's do_append() function,
}
}
-static void _xbt_log_cat_apply_set(xbt_log_category_t category,
- xbt_log_setting_t setting);
+static void _xbt_log_cat_apply_set(xbt_log_category_t category, xbt_log_setting_t setting);
const char *xbt_log_priority_names[8] = {
"NONE",
0 /* additivity */
};
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(log, xbt,
- "Loggings from the logging mechanism itself");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(log, xbt, "Loggings from the logging mechanism itself");
/* create the default appender and install it in the root category,
which were already created (damnit. Too slow little beetle) */
xbt_log_default_layout = xbt_log_layout_simple_new(NULL);
_XBT_LOGV(XBT_LOG_ROOT_CAT).appender = xbt_log_default_appender;
_XBT_LOGV(XBT_LOG_ROOT_CAT).layout = xbt_log_default_layout;
- log_cat_init_mutex = xbt_os_rmutex_init();
+ log_cat_init_mutex = xbt_os_mutex_init();
}
static void xbt_log_connect_categories(void)
/* xbt */
XBT_LOG_CONNECT(xbt);
- XBT_LOG_CONNECT(graphxml_parse);
XBT_LOG_CONNECT(log);
XBT_LOG_CONNECT(module);
XBT_LOG_CONNECT(replay);
XBT_LOG_CONNECT(xbt_dict);
XBT_LOG_CONNECT(xbt_dict_cursor);
XBT_LOG_CONNECT(xbt_dict_elm);
-#ifdef XBT_USE_DEPRECATED
- XBT_LOG_CONNECT(xbt_dict_multi);
-#endif
XBT_LOG_CONNECT(xbt_dyn);
XBT_LOG_CONNECT(xbt_ex);
XBT_LOG_CONNECT(xbt_fifo);
/* The following categories are only defined in libsimgrid */
/* bindings */
-#ifdef HAVE_LUA
- XBT_LOG_CONNECT(bindings);
+#if HAVE_LUA
XBT_LOG_CONNECT(lua);
XBT_LOG_CONNECT(lua_host);
XBT_LOG_CONNECT(lua_platf);
XBT_LOG_CONNECT(instr_TI_trace);
/* jedule */
-#ifdef HAVE_JEDULE
+#if HAVE_JEDULE
XBT_LOG_CONNECT(jedule);
XBT_LOG_CONNECT(jed_out);
XBT_LOG_CONNECT(jed_sd);
#endif
/* mc */
-#ifdef HAVE_MC
+#if HAVE_MC
XBT_LOG_CONNECT(mc);
XBT_LOG_CONNECT(mc_checkpoint);
XBT_LOG_CONNECT(mc_comm_determinism);
XBT_LOG_CONNECT(mc_diff);
XBT_LOG_CONNECT(mc_dwarf);
XBT_LOG_CONNECT(mc_hash);
- XBT_LOG_CONNECT(mc_ignore);
XBT_LOG_CONNECT(mc_liveness);
XBT_LOG_CONNECT(mc_memory);
XBT_LOG_CONNECT(mc_page_snapshot);
XBT_LOG_CONNECT(mc_request);
XBT_LOG_CONNECT(mc_safety);
- XBT_LOG_CONNECT(mc_visited);
+ XBT_LOG_CONNECT(mc_VisitedState);
XBT_LOG_CONNECT(mc_client);
XBT_LOG_CONNECT(mc_client_api);
XBT_LOG_CONNECT(mc_comm_pattern);
/* simdag */
XBT_LOG_CONNECT(sd);
XBT_LOG_CONNECT(sd_daxparse);
-#ifdef HAVE_GRAPHVIZ
+#if HAVE_GRAPHVIZ
XBT_LOG_CONNECT(sd_dotparse);
#endif
XBT_LOG_CONNECT(sd_kernel);
XBT_LOG_CONNECT(surf_lagrange_dichotomy);
XBT_LOG_CONNECT(surf_maxmin);
XBT_LOG_CONNECT(surf_network);
-#ifdef HAVE_NS3
+#if HAVE_NS3
XBT_LOG_CONNECT(ns3);
#endif
XBT_LOG_CONNECT(surf_parse);
void xbt_log_postexit(void)
{
XBT_VERB("Exiting log");
- xbt_os_rmutex_destroy(log_cat_init_mutex);
+ xbt_os_mutex_destroy(log_cat_init_mutex);
xbt_dynar_free(&xbt_log_settings);
log_cat_exit(&_XBT_LOGV(XBT_LOG_ROOT_CAT));
}
{
xbt_log_category_t cat = ev->cat;
- xbt_assert(ev->priority >= 0,
- "Negative logging priority naturally forbidden");
- xbt_assert(ev->priority < sizeof(xbt_log_priority_names),
- "Priority %d is greater than the biggest allowed value",
+ xbt_assert(ev->priority >= 0, "Negative logging priority naturally forbidden");
+ xbt_assert(ev->priority < sizeof(xbt_log_priority_names), "Priority %d is greater than the biggest allowed value",
ev->priority);
do {
if (!appender)
continue; /* No appender, try next */
- xbt_assert(cat->layout,
- "No valid layout for the appender of category %s", cat->name);
+ xbt_assert(cat->layout, "No valid layout for the appender of category %s", cat->name);
/* First, try with a static buffer */
if (XBT_LOG_STATIC_BUFFER_SIZE) {
/* NOTE:
*
- * The standard logging macros use _XBT_LOG_ISENABLED, which calls
- * _xbt_log_cat_init(). Thus, if we want to avoid an infinite
- * recursion, we can not use the standard logging macros in
- * _xbt_log_cat_init(), and in all functions called from it.
+ * The standard logging macros use _XBT_LOG_ISENABLED, which calls _xbt_log_cat_init(). Thus, if we want to avoid an
+ * infinite recursion, we can not use the standard logging macros in _xbt_log_cat_init(), and in all functions called
+ * from it.
*
- * To circumvent the problem, we define the macro_xbt_log_init() as
- * (0) for the length of the affected functions, and we do not forget
- * to undefine it at the end!
+ * To circumvent the problem, we define the macro_xbt_log_init() as (0) for the length of the affected functions, and
+ * we do not forget to undefine it at the end!
*/
-static void _xbt_log_cat_apply_set(xbt_log_category_t category,
- xbt_log_setting_t setting)
+static void _xbt_log_cat_apply_set(xbt_log_category_t category, xbt_log_setting_t setting)
{
#define _xbt_log_cat_init(a, b) (0)
xbt_log_threshold_set(category, setting->thresh);
XBT_DEBUG("Apply settings for category '%s': set threshold to %s (=%d)",
- category->name, xbt_log_priority_names[category->threshold],
- category->threshold);
+ category->name, xbt_log_priority_names[category->threshold], category->threshold);
}
if (setting->fmt) {
xbt_log_layout_set(category, xbt_log_layout_format_new(setting->fmt));
- XBT_DEBUG("Apply settings for category '%s': set format to %s",
- category->name, setting->fmt);
+ XBT_DEBUG("Apply settings for category '%s': set format to %s", category->name, setting->fmt);
}
if (setting->additivity != -1) {
if (!category->layout)
xbt_log_layout_set(category, xbt_log_layout_simple_new(NULL));
category->additivity = 0;
- XBT_DEBUG("Set %p as appender of category '%s'",
- setting->appender, category->name);
+ XBT_DEBUG("Set %p as appender of category '%s'", setting->appender, category->name);
}
#undef _xbt_log_cat_init
}
/*
- * This gets called the first time a category is referenced and performs the
- * initialization.
+ * This gets called the first time a category is referenced and performs the initialization.
* Also resets threshold to inherited!
*/
-int _xbt_log_cat_init(xbt_log_category_t category,
- e_xbt_log_priority_t priority)
+int _xbt_log_cat_init(xbt_log_category_t category, e_xbt_log_priority_t priority)
{
#define _xbt_log_cat_init(a, b) (0)
- if (log_cat_init_mutex != NULL) {
- xbt_os_rmutex_acquire(log_cat_init_mutex);
- }
+ if (log_cat_init_mutex != NULL)
+ xbt_os_mutex_acquire(log_cat_init_mutex);
if (category->initialized) {
- if (log_cat_init_mutex != NULL) {
- xbt_os_rmutex_release(log_cat_init_mutex);
- }
+ if (log_cat_init_mutex != NULL)
+ xbt_os_mutex_release(log_cat_init_mutex);
return priority >= category->threshold;
}
xbt_log_setting_t setting = NULL;
int found = 0;
- XBT_DEBUG("Initializing category '%s' (firstChild=%s, nextSibling=%s)",
- category->name,
+ XBT_DEBUG("Initializing category '%s' (firstChild=%s, nextSibling=%s)", category->name,
(category->firstChild ? category->firstChild->name : "none"),
(category->nextSibling ? category->nextSibling->name : "none"));
category->appender = xbt_log_default_appender;
category->layout = xbt_log_default_layout;
} else {
-
if (!category->parent)
category->parent = &_XBT_LOGV(XBT_LOG_ROOT_CAT);
- XBT_DEBUG("Set %s (%s) as father of %s ",
- category->parent->name,
- (category->parent->initialized ?
- xbt_log_priority_names[category->parent->threshold] : "uninited"),
+ XBT_DEBUG("Set %s (%s) as father of %s ", category->parent->name,
+ (category->parent->initialized ? xbt_log_priority_names[category->parent->threshold] : "uninited"),
category->name);
xbt_log_parent_set(category, category->parent);
cpp = cpp->nextSibling;
}
- XBT_DEBUG("Children of %s: %s; nextSibling: %s",
- category->parent->name, res,
- (category->parent->nextSibling ?
- category->parent->nextSibling->name : "none"));
+ XBT_DEBUG("Children of %s: %s; nextSibling: %s", category->parent->name, res,
+ (category->parent->nextSibling ? category->parent->nextSibling->name : "none"));
free(res);
}
-
}
/* Apply the control */
xbt_dynar_foreach(xbt_log_settings, cursor, setting) {
xbt_assert(setting, "Damnit, NULL cat in the list");
- xbt_assert(setting->catname, "NULL setting(=%p)->catname",
- (void *) setting);
+ xbt_assert(setting->catname, "NULL setting(=%p)->catname", (void *) setting);
if (!strcmp(setting->catname, category->name)) {
found = 1;
if (!found)
XBT_DEBUG("Category '%s': inherited threshold = %s (=%d)",
- category->name, xbt_log_priority_names[category->threshold],
- category->threshold);
+ category->name, xbt_log_priority_names[category->threshold], category->threshold);
}
category->initialized = 1;
- if (log_cat_init_mutex != NULL) {
- xbt_os_rmutex_release(log_cat_init_mutex);
- }
+ if (log_cat_init_mutex != NULL)
+ xbt_os_mutex_release(log_cat_init_mutex);
return priority >= category->threshold;
#undef _xbt_log_cat_init
/* if the category is initialized, unlink from current parent */
if (cat->initialized) {
-
xbt_log_category_t *cpp = &cat->parent->firstChild;
while (*cpp != cat && *cpp != NULL) {
static void _set_inherited_thresholds(xbt_log_category_t cat)
{
-
xbt_log_category_t child = cat->firstChild;
for (; child != NULL; child = child->nextSibling) {
if (child->isThreshInherited) {
if (cat != &_XBT_LOGV(log))
XBT_VERB("Set category threshold of %s to %s (=%d)",
- child->name, xbt_log_priority_names[cat->threshold],
- cat->threshold);
+ child->name, xbt_log_priority_names[cat->threshold], cat->threshold);
child->threshold = cat->threshold;
_set_inherited_thresholds(child);
}
}
-
-
}
-void xbt_log_threshold_set(xbt_log_category_t cat,
- e_xbt_log_priority_t threshold)
+void xbt_log_threshold_set(xbt_log_category_t cat, e_xbt_log_priority_t threshold)
{
cat->threshold = threshold;
cat->isThreshInherited = 0;
_set_inherited_thresholds(cat);
-
}
static xbt_log_setting_t _xbt_log_parse_setting(const char *control_string)
set->thresh = (e_xbt_log_priority_t) i;
} else {
THROWF(arg_error, 0,
- "Unknown priority name: %s (must be one of: trace,debug,verbose,info,warning,error,critical)",
- eq + 1);
+ "Unknown priority name: %s (must be one of: trace,debug,verbose,info,warning,error,critical)", eq + 1);
}
free(neweq);
} else if (!strncmp(dot + 1, "add", (size_t) (eq - dot - 1)) ||
!strncmp(dot + 1, "additivity", (size_t) (eq - dot - 1))) {
-
char *neweq = xbt_strdup(eq + 1);
char *p = neweq - 1;
*p -= 'a' - 'A';
}
}
- if (!strcmp(neweq, "ON") || !strcmp(neweq, "YES")
- || !strcmp(neweq, "1")) {
+ if (!strcmp(neweq, "ON") || !strcmp(neweq, "YES") || !strcmp(neweq, "1")) {
set->additivity = 1;
} else {
set->additivity = 0;
free(neweq);
} else if (!strncmp(dot + 1, "app", (size_t) (eq - dot - 1)) ||
!strncmp(dot + 1, "appender", (size_t) (eq - dot - 1))) {
-
char *neweq = xbt_strdup(eq + 1);
if (!strncmp(neweq, "file:", 5)) {
set->fmt = xbt_strdup(eq + 1);
} else {
char buff[512];
- snprintf(buff, min(512, eq - dot), "%s", dot + 1);
- THROWF(arg_error, 0, "Unknown setting of the log category: '%s'",
- buff);
+ snprintf(buff, MIN(512, eq - dot), "%s", dot + 1);
+ THROWF(arg_error, 0, "Unknown setting of the log category: '%s'", buff);
}
set->catname = (char *) xbt_malloc(dot - name + 1);
return set;
}
-static xbt_log_category_t _xbt_log_cat_searchsub(xbt_log_category_t cat,
- char *name)
+static xbt_log_category_t _xbt_log_cat_searchsub(xbt_log_category_t cat, char *name)
{
xbt_log_category_t child, res;
*
* ( [category] "." [keyword] ":" value (" ")... )...
*
- * where [category] is one the category names (see \ref XBT_log_cats for
- * a complete list of the ones defined in the SimGrid library)
- * and keyword is one of the following:
+ * where [category] is one the category names (see \ref XBT_log_cats for a complete list of the ones defined in the
+ * SimGrid library) and keyword is one of the following:
*
* - thres: category's threshold priority. Possible values:
* TRACE,DEBUG,VERBOSE,INFO,WARNING,ERROR,CRITICAL
- * - add or additivity: whether the logging actions must be passed to
- * the parent category.
+ * - add or additivity: whether the logging actions must be passed to the parent category.
* Possible values: 0, 1, no, yes, on, off.
* Default value: yes.
* - fmt: the format to use. See \ref log_use_conf_fmt for more information.
- * - app or appender: the appender to use. See \ref log_use_conf_app for more
- * information.
- *
+ * - app or appender: the appender to use. See \ref log_use_conf_app for more information.
*/
void xbt_log_control_set(const char *control_string)
{
}
/* some initialization if this is the first time that this get called */
if (xbt_log_settings == NULL)
- xbt_log_settings = xbt_dynar_new(sizeof(xbt_log_setting_t),
- _free_setting);
+ xbt_log_settings = xbt_dynar_new(sizeof(xbt_log_setting_t), _free_setting);
/* split the string, and remove empty entries */
set_strings = xbt_str_split_quoted(control_string);
return;
}
- /* Parse each entry and either use it right now (if the category was already
- created), or store it for further use */
+ /* Parse each entry and either use it right now (if the category was already created), or store it for further use */
xbt_dynar_foreach(set_strings, cpt, str) {
xbt_log_category_t cat = NULL;
set = _xbt_log_parse_setting(str);
- cat =
- _xbt_log_cat_searchsub(&_XBT_LOGV(XBT_LOG_ROOT_CAT), set->catname);
+ cat = _xbt_log_cat_searchsub(&_XBT_LOGV(XBT_LOG_ROOT_CAT), set->catname);
if (cat) {
XBT_DEBUG("Apply directly");
_xbt_log_cat_apply_set(cat, set);
_free_setting((void *) &set);
} else {
-
XBT_DEBUG("Store for further application");
XBT_DEBUG("push %p to the settings", (void *) set);
xbt_dynar_push(xbt_log_settings, &set);
{
#define _xbt_log_cat_init(a, b) (0)
if (!cat->appender) {
- XBT_VERB
- ("No appender to category %s. Setting the file appender as default",
- cat->name);
+ XBT_VERB ("No appender to category %s. Setting the file appender as default", cat->name);
xbt_log_appender_set(cat, xbt_log_appender_file_new(NULL));
}
if (cat->layout) {
return strcmp(a->name, b->name);
}
-static void xbt_log_help_categories_rec(xbt_log_category_t category,
- const char *prefix)
+static void xbt_log_help_categories_rec(xbt_log_category_t category, const char *prefix)
{
char *this_prefix;
char *child_prefix;