Add a new sr_log_callback_get() API call.
This commit is contained in:
parent
8bc8e9094c
commit
ee425a466a
|
@ -67,6 +67,7 @@ SR_API int sr_log_loglevel_set(int loglevel);
|
||||||
SR_API int sr_log_loglevel_get(void);
|
SR_API int sr_log_loglevel_get(void);
|
||||||
SR_API int sr_log_callback_set(sr_log_callback cb, void *cb_data);
|
SR_API int sr_log_callback_set(sr_log_callback cb, void *cb_data);
|
||||||
SR_API int sr_log_callback_set_default(void);
|
SR_API int sr_log_callback_set_default(void);
|
||||||
|
SR_API int sr_log_callback_get(sr_log_callback *cb, void **cb_data);
|
||||||
|
|
||||||
/*--- device.c --------------------------------------------------------------*/
|
/*--- device.c --------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
22
src/log.c
22
src/log.c
|
@ -160,6 +160,28 @@ SR_API int sr_log_callback_set_default(void)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the libsigrok log callback routine and callback data.
|
||||||
|
*
|
||||||
|
* @param[out] cb Pointer to a function pointer to receive the log callback
|
||||||
|
* function. Optional, can be NULL.
|
||||||
|
* @param[out] cb_data Pointer to a void pointer to receive the log callback's
|
||||||
|
* additional arguments. Optional, can be NULL.
|
||||||
|
*
|
||||||
|
* @return SR_OK upon success.
|
||||||
|
*
|
||||||
|
* @since 0.6.0
|
||||||
|
*/
|
||||||
|
SR_API int sr_log_callback_get(sr_log_callback *cb, void **cb_data)
|
||||||
|
{
|
||||||
|
if (cb)
|
||||||
|
*cb = sr_log_cb;
|
||||||
|
if (cb_data)
|
||||||
|
*cb_data = sr_log_cb_data;
|
||||||
|
|
||||||
|
return SR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static int sr_logv(void *cb_data, int loglevel, const char *format, va_list args)
|
static int sr_logv(void *cb_data, int loglevel, const char *format, va_list args)
|
||||||
{
|
{
|
||||||
uint64_t elapsed_us, minutes;
|
uint64_t elapsed_us, minutes;
|
||||||
|
|
Loading…
Reference in New Issue