This topic describes the syntax of external log callback and built-in log callback functions.
External log callback
The following code shows the syntax of the external log callback function:
int (* output_log)(
void *s,
int level,
const char *fmt,
va_list args
);
Parameters
Parameter | Type | Description |
---|---|---|
s | void * | The value of this parameter is determined by the LogCbParam parameter of the preconfig method. The value is passed to the output_log method.
|
level | int | The level of the logs to be filtered. Valid values:
|
fmt | const char * | The formatted string. The value of this parameter is the same as that of the format parameter in the printf method.
|
args | va_list | The list of variable parameters. |
Example
In this example, the external log callback function is set for Native RTS SDK by using the preconfig method, as shown in the following code:
// Invoke a callback function.
static int output_log(struct AVFormatContext *s, int level, const char *fmt, va_list args)
{
// TODO: Process logs.
return 0;
}
// Set the callback function for Native RTS SDK.
__rts_funcs->preconfig("LogCallback", addr_to_string(output_log, buf));
__rts_funcs->preconfig("LogCbParam", addr_to_string(s, buf));
For more information about the external log callback function, see the rtsdec.c file of Native RTS SDK.
Built-in log callback
The built-in log callback function is implemented by using the preconfig method. The following code shows the syntax of the built-in log callback function:
int (* preconfig)(
const char *key,
const char *val
);
Parameters
Parameter | Type | Description |
---|---|---|
key | const char * | The name of the parameter. The name is case-sensitive. For more information, see the following table. |
val | const char * | The value of parameter. |
Parameter | Description |
---|---|
LogToConsole | Specifies whether to export built-in logs to the console. |
LogToFile | Specifies whether to export built-in logs to a file. |
LogToServer | Specifies whether to push built-in logs to a server. |
LogLevel | The level of the logs to be filtered. Only logs of the required or higher levels are
exported or pushed. Valid values:
|
Example
__rts_funcs->preconfig("LogToConsole", "true"); //output to console
__rts_funcs->preconfig("LogToFile", "true"); //output to file
__rts_funcs->preconfig("LogToServer", "true"); //output to server
__rts_funcs->preconfig("LogLevel", "2"); //LOG_INFO