Added an option to color out the ouput
[src/app-framework-binder.git] / src / afb-export.c
index e679b76..fb1888e 100644 (file)
@@ -274,7 +274,7 @@ static void vverbose_cb(struct afb_api_x3 *closure, int level, const char *file,
        if (!fmt || vasprintf(&p, fmt, args) < 0)
                vverbose(level, file, line, function, fmt, args);
        else {
-               verbose(level, file, line, function, "[API %s] %s", export->api.apiname, p);
+               verbose(level, file, line, function, (verbose_is_colorized() == 0 ? "[API %s] %s" : COLOR_API "[API %s]" COLOR_DEFAULT " %s"), export->api.apiname, p);
                free(p);
        }
 }
@@ -352,6 +352,11 @@ static int require_api_cb(struct afb_api_x3 *closure, const char *name, int init
        int rc, rc2;
        char *iter, *end, save;
 
+       /* emit a warning about unexpected require in preinit */
+       if (export->state == Api_State_Pre_Init)
+               WARNING("[API %s] requiring apis in pre-init may lead to unexpected result (requires%s: %s)",
+                       export->api.apiname, initialized ? " initialized" : "", name);
+
        /* scan the names in a local copy */
        rc = 0;
        iter = strdupa(name);