void BKE_report(ReportList *reports, ReportType type, const char *message) { Report *report; int len; /* in background mode always print otherwise there are cases the errors wont be displayed, * but still add to the report list since this is used for python exception handling */ if (G.background || !reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) { printf("%s: %s\n", report_type_str(type), message); fflush(stdout); /* this ensures the message is printed before a crash */ } if (reports && (reports->flag & RPT_STORE) && (type >= reports->storelevel)) { char *message_alloc; report= MEM_callocN(sizeof(Report), "Report"); report->type= type; report->typestr= report_type_str(type); len= strlen(message); message_alloc= MEM_callocN(sizeof(char)*(len+1), "ReportMessage"); memcpy(message_alloc, message, sizeof(char)*(len+1)); report->message= message_alloc; report->len= len; BLI_addtail(&reports->list, report); } }
void BKE_reportf(ReportList *reports, ReportType type, const char *_format, ...) { DynStr *ds; Report *report; va_list args; const char *format = TIP_(_format); if (G.background || !reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) { printf("%s: ", report_type_str(type)); va_start(args, _format); vprintf(format, args); va_end(args); fprintf(stdout, "\n"); /* otherise each report needs to include a \n */ fflush(stdout); /* this ensures the message is printed before a crash */ } if (reports && (reports->flag & RPT_STORE) && (type >= reports->storelevel)) { report = MEM_callocN(sizeof(Report), "Report"); ds = BLI_dynstr_new(); va_start(args, _format); BLI_dynstr_vappendf(ds, format, args); va_end(args); report->message = BLI_dynstr_get_cstring(ds); report->len = BLI_dynstr_get_len(ds); BLI_dynstr_free(ds); report->type = type; report->typestr = report_type_str(type); BLI_addtail(&reports->list, report); } }