helper/log: Add macros for target-related errors/warnings/... 67/6667/3
authorJan Matyas <matyas@codasip.com>
Mon, 1 Nov 2021 14:28:28 +0000 (15:28 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 13 Nov 2021 10:51:52 +0000 (10:51 +0000)
This commit introduces macros for target related log entries
(error, warning, ...) which is a very common operation in OpenOCD:

* LOG_TARGET_ERROR
* LOG_TARGET_WARNING
* LOG_TARGET_INFO
* LOG_TARGET_DEBUG
* LOG_TARGET_DEBUG_IO

The goal is to have one macro for this common operation and to
make such log entries look the same way - to make it more readable
for humans as well easier for parsing via scripts.

Change-Id: I6166565fc9040b03d3fca5c3aa44a1ccbcf96ad2
Signed-off-by: Jan Matyas <matyas@codasip.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6667
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
src/helper/log.h

index 34ff835b81ba9cae19929a6de9341d39fc44dc0e..621d467b49e9e4697ae686562f1fceb0cc7ee648 100644 (file)
@@ -143,6 +143,23 @@ extern int debug_level;
 #define LOG_OUTPUT(expr ...) \
        log_printf(LOG_LVL_OUTPUT, __FILE__, __LINE__, __func__, expr)
 
+/* Output a log entry that is related to a given target */
+
+#define LOG_TARGET_DEBUG_IO(target, fmt_str, ...) \
+       LOG_DEBUG_IO("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)
+
+#define LOG_TARGET_DEBUG(target, fmt_str, ...) \
+       LOG_DEBUG("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)
+
+#define LOG_TARGET_INFO(target, fmt_str, ...) \
+       LOG_INFO("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)
+
+#define LOG_TARGET_WARNING(target, fmt_str, ...) \
+       LOG_WARNING("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)
+
+#define LOG_TARGET_ERROR(target, fmt_str, ...) \
+       LOG_ERROR("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)
+
 /* general failures
  * error codes < 100
  */

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)