Example #1
0
static void logger(void *data, mrp_log_level_t level, const char *file,
                   int line, const char *func, const char *format, va_list ap)
{
    console_t  *c = (console_t *)data;
    va_list     cp;
    const char *prefix;

    MRP_UNUSED(file);
    MRP_UNUSED(line);
    MRP_UNUSED(func);

    switch (level) {
    case MRP_LOG_ERROR:   prefix = "[log] E: "; break;
    case MRP_LOG_WARNING: prefix = "[log] W: "; break;
    case MRP_LOG_INFO:    prefix = "[log] I: "; break;
    case MRP_LOG_DEBUG:   prefix = "[log] D: "; break;
    default:              prefix = "[log] ?: ";
    }

    va_copy(cp, ap);
    mrp_console_printf(c->mc, "%s", prefix);
    mrp_console_vprintf(c->mc, format, cp);
    mrp_console_printf(c->mc, "\n");
    va_end(cp);
}
Example #2
0
void invoke_reply(int error, int retval, int narg, mrp_domctl_arg_t *args,
                  void *user_data)
{
    mrp_console_t *c = (mrp_console_t *)user_data;
    int            i;

    if (error) {
        mrp_console_printf(c, "invoked method failed with error code %d\n",
                           error);
        return;
    }

    mrp_console_printf(c, "invoked method returned (return value %d)\n", retval);

    for (i = 0; i < narg; i++) {
        switch (args[i].type) {
        case MRP_DOMCTL_STRING:
            mrp_console_printf(c, "    #%d: %s\n", i, args[i].str);
            break;
        case MRP_DOMCTL_UINT16:
            mrp_console_printf(c, "    #%d: %u\n", i, args[i].u16);
            break;
        case MRP_DOMCTL_INT16:
            mrp_console_printf(c, "    #%d: %u\n", i, args[i].s16);
            break;
        case MRP_DOMCTL_UINT32:
            mrp_console_printf(c, "    #%d: %u\n", i, args[i].u32);
            break;
        case MRP_DOMCTL_INT32:
            mrp_console_printf(c, "    #%d: %u\n", i, args[i].s32);
            break;
        default:
            mrp_console_printf(c, "    #%d: <type 0x%x\n", i, args[i].type);
            break;
        }
    }
}