+ unsigned int cursor;
+ xbt_log_setting_t setting = NULL;
+ int found = 0;
+ s_xbt_log_event_t _log_ev;
+
+ if (_XBT_LOGV(log).threshold <= xbt_log_priority_debug
+ && _XBT_LOGV(log).threshold != xbt_log_priority_uninitialized) {
+ _log_ev.cat = &_XBT_LOGV(log);
+ _log_ev.priority = xbt_log_priority_debug;
+ _log_ev.fileName = __FILE__;
+ _log_ev.functionName = _XBT_FUNCTION;
+ _log_ev.lineNum = __LINE__;
+ _xbt_log_event_log(&_log_ev,
+ "Initializing category '%s' (firstChild=%s, nextSibling=%s)",
+ category->name,
+ (category->firstChild ? category->
+ firstChild->name : "none"),
+ (category->nextSibling ? category->
+ nextSibling->name : "none"));
+ }
+
+ if (category == &_XBT_LOGV(XBT_LOG_ROOT_CAT)) {
+ category->threshold = xbt_log_priority_info;
+ /* xbt_log_priority_debug */ ;
+ category->appender = xbt_log_default_appender;
+ category->layout = xbt_log_default_layout;
+ } else {
+
+ if (!category->parent)
+ category->parent = &_XBT_LOGV(XBT_LOG_ROOT_CAT);
+
+ if (_XBT_LOGV(log).threshold <= xbt_log_priority_debug
+ && _XBT_LOGV(log).threshold != xbt_log_priority_uninitialized) {
+ _log_ev.lineNum = __LINE__;
+ _xbt_log_event_log(&_log_ev, "Set %s (%s) as father of %s ",
+ category->parent->name,
+ (category->parent->threshold ==
+ xbt_log_priority_uninitialized ? "uninited" :
+ xbt_log_priority_names[category->
+ parent->threshold]),
+ category->name);
+ }
+ xbt_log_parent_set(category, category->parent);
+
+ if (_XBT_LOGV(log).threshold < xbt_log_priority_info
+ && _XBT_LOGV(log).threshold != xbt_log_priority_uninitialized) {
+ char *buf, *res = NULL;
+ xbt_log_category_t cpp = category->parent->firstChild;
+ while (cpp) {
+ if (res) {
+ buf = bprintf("%s %s", res, cpp->name);
+ free(res);
+ res = buf;
+ } else {
+ res = xbt_strdup(cpp->name);
+ }
+ cpp = cpp->nextSibling;
+ }
+
+ _log_ev.lineNum = __LINE__;
+ _xbt_log_event_log(&_log_ev,
+ "Childs of %s: %s; nextSibling: %s",
+ category->parent->name, res,
+ (category->parent->nextSibling ? category->
+ parent->nextSibling->name : "none"));
+
+ free(res);
+ }
+
+ }
+
+ /* Apply the control */
+ if (!xbt_log_settings)
+ return priority >= category->threshold;
+
+ xbt_assert0(category, "NULL category");
+ xbt_assert(category->name);
+
+ xbt_dynar_foreach(xbt_log_settings, cursor, setting) {
+ xbt_assert0(setting, "Damnit, NULL cat in the list");
+ xbt_assert1(setting->catname, "NULL setting(=%p)->catname",
+ (void *) setting);
+
+ if (!strcmp(setting->catname, category->name)) {
+
+ found = 1;
+
+ _xbt_log_cat_apply_set(category, setting);
+
+ xbt_dynar_cursor_rm(xbt_log_settings, &cursor);
+ }
+ }
+
+ if (!found && category->threshold <= xbt_log_priority_verbose) {
+
+ _log_ev.cat = &_XBT_LOGV(log);
+ _log_ev.priority = xbt_log_priority_verbose;
+ _log_ev.fileName = __FILE__;
+ _log_ev.functionName = _XBT_FUNCTION;
+ _log_ev.lineNum = __LINE__;
+
+ _xbt_log_event_log(&_log_ev,
+ "Category '%s': inherited threshold = %s (=%d)",
+ category->name,
+ xbt_log_priority_names[category->threshold],
+ category->threshold);
+ }
+
+ return priority >= category->threshold;