jlink: Adjust log verbosity of libjaylink
Currently, the log verbosity of libjaylink is not accessible from the user interface. Therefore, changing the log verbosity of libjaylink is only possible from within the J-Link driver source code which is not acceptable for end users. Output the libjaylink log messages through the logging module of OpenOCD rather than directly to stderr. Change-Id: I6bf7bf8f4c8a12fb9e955eeced68224545fa0b5c Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/3701 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>
This commit is contained in:
parent
3c8832fe6e
commit
8515da60a8
|
@ -502,6 +502,35 @@ static bool adjust_swd_buffer_size(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
static int jaylink_log_handler(const struct jaylink_context *ctx, int level,
|
||||
const char *format, va_list args, void *user_data)
|
||||
{
|
||||
enum log_levels tmp;
|
||||
|
||||
switch (level) {
|
||||
case JAYLINK_LOG_LEVEL_ERROR:
|
||||
tmp = LOG_LVL_ERROR;
|
||||
break;
|
||||
case JAYLINK_LOG_LEVEL_WARNING:
|
||||
tmp = LOG_LVL_WARNING;
|
||||
break;
|
||||
/*
|
||||
* Forward info messages to the debug output because they are more verbose
|
||||
* than info messages of OpenOCD.
|
||||
*/
|
||||
case JAYLINK_LOG_LEVEL_INFO:
|
||||
case JAYLINK_LOG_LEVEL_DEBUG:
|
||||
tmp = LOG_LVL_DEBUG;
|
||||
break;
|
||||
default:
|
||||
tmp = LOG_LVL_WARNING;
|
||||
}
|
||||
|
||||
log_vprintf_lf(tmp, __FILE__, __LINE__, __func__, format, args);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int jlink_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
@ -523,6 +552,15 @@ static int jlink_init(void)
|
|||
return ERROR_JTAG_INIT_FAILED;
|
||||
}
|
||||
|
||||
ret = jaylink_log_set_callback(jayctx, &jaylink_log_handler, NULL);
|
||||
|
||||
if (ret != JAYLINK_OK) {
|
||||
LOG_ERROR("jaylink_log_set_callback() failed: %s.",
|
||||
jaylink_strerror_name(ret));
|
||||
jaylink_exit(jayctx);
|
||||
return ERROR_JTAG_INIT_FAILED;
|
||||
}
|
||||
|
||||
ret = jaylink_get_device_list(jayctx, &devs);
|
||||
|
||||
if (ret < 0) {
|
||||
|
|
Loading…
Reference in New Issue