jlink: Adjust log verbosity of libjaylink
[openocd.git] / src / jtag / drivers / jlink.c
index 30090582336029d8303f6f8bdba01763e032186f..441e3efad94b3e6198beb659337392f4181ba97b 100644 (file)
@@ -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) {

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)