Skip to content

Commit 78acc9b

Browse files
committed
Implement logging functionality for OpenFX messages
1 parent 19d8b74 commit 78acc9b

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

src/modules/openfx/mlt_openfx.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,9 +1500,76 @@ static OfxMultiThreadSuiteV1 MltOfxMultiThreadSuiteV1 = {multiThread,
15001500
mutexUnLock,
15011501
mutexTryLock};
15021502

1503+
static void mltofx_log_message(const char *kind,
1504+
const char *messageType,
1505+
const char *messageId,
1506+
const char *format,
1507+
va_list ap)
1508+
{
1509+
char formatted[1024] = "";
1510+
const char *type = messageType ? messageType : "OfxMessageUnknown";
1511+
const char *id = (messageId && messageId[0]) ? messageId : NULL;
1512+
1513+
if (format && format[0]) {
1514+
vsnprintf(formatted, sizeof(formatted), format, ap);
1515+
}
1516+
1517+
if (strcmp(type, "OfxMessageFatal") == 0) {
1518+
mlt_log_fatal(NULL,
1519+
"[openfx] %s type=%s%s%s%s%s\n",
1520+
kind,
1521+
type,
1522+
id ? " id=" : "",
1523+
id ? id : "",
1524+
formatted[0] ? " msg=" : "",
1525+
formatted);
1526+
} else if (strcmp(type, "OfxMessageError") == 0) {
1527+
mlt_log_error(NULL,
1528+
"[openfx] %s type=%s%s%s%s%s\n",
1529+
kind,
1530+
type,
1531+
id ? " id=" : "",
1532+
id ? id : "",
1533+
formatted[0] ? " msg=" : "",
1534+
formatted);
1535+
} else if (strcmp(type, "OfxMessageWarning") == 0) {
1536+
mlt_log_warning(NULL,
1537+
"[openfx] %s type=%s%s%s%s%s\n",
1538+
kind,
1539+
type,
1540+
id ? " id=" : "",
1541+
id ? id : "",
1542+
formatted[0] ? " msg=" : "",
1543+
formatted);
1544+
} else if (strcmp(type, "OfxMessageLog") == 0) {
1545+
mlt_log_verbose(NULL,
1546+
"[openfx] %s type=%s%s%s%s%s\n",
1547+
kind,
1548+
type,
1549+
id ? " id=" : "",
1550+
id ? id : "",
1551+
formatted[0] ? " msg=" : "",
1552+
formatted);
1553+
} else {
1554+
mlt_log_info(NULL,
1555+
"[openfx] %s type=%s%s%s%s%s\n",
1556+
kind,
1557+
type,
1558+
id ? " id=" : "",
1559+
id ? id : "",
1560+
formatted[0] ? " msg=" : "",
1561+
formatted);
1562+
}
1563+
}
1564+
15031565
static OfxStatus message(
15041566
void *handle, const char *messageType, const char *messageId, const char *format, ...)
15051567
{
1568+
(void) handle;
1569+
va_list ap;
1570+
va_start(ap, format);
1571+
mltofx_log_message("message", messageType, messageId, format, ap);
1572+
va_end(ap);
15061573
return kOfxStatOK;
15071574
}
15081575

@@ -1511,11 +1578,18 @@ static OfxMessageSuiteV1 MltOfxMessageSuiteV1 = {message};
15111578
static OfxStatus setPersistentMessage(
15121579
void *handle, const char *messageType, const char *messageId, const char *format, ...)
15131580
{
1581+
(void) handle;
1582+
va_list ap;
1583+
va_start(ap, format);
1584+
mltofx_log_message("persistent", messageType, messageId, format, ap);
1585+
va_end(ap);
15141586
return kOfxStatOK;
15151587
}
15161588

15171589
static OfxStatus clearPersistentMessage(void *handle)
15181590
{
1591+
(void) handle;
1592+
mlt_log_debug(NULL, "[openfx] persistent message cleared\n");
15191593
return kOfxStatOK;
15201594
}
15211595

0 commit comments

Comments
 (0)