From 3829332a558f759874b71935e199927334feb2bb Mon Sep 17 00:00:00 2001 From: zhangyuan21 Date: Thu, 27 Jul 2023 15:22:55 +0800 Subject: [PATCH] adb: add adb log level Signed-off-by: zhangyuan21 --- system/adb/adb_banner.c | 2 +- system/adb/adb_main.c | 22 ++++++++++++++++++++-- system/adb/logcat_service.c | 6 +++--- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/system/adb/adb_banner.c b/system/adb/adb_banner.c index e1c54fbbbe4..6983b713515 100644 --- a/system/adb/adb_banner.c +++ b/system/adb/adb_banner.c @@ -50,7 +50,7 @@ int adb_fill_connect_data(char *buf, size_t bufsize) { /* Failed to get board id */ - adb_log("failed to get board id\n"); + adb_err("failed to get board id\n"); len = snprintf(buf, remaining, "device::"); } else diff --git a/system/adb/adb_main.c b/system/adb/adb_main.c index 6401789f814..5110d6edd55 100644 --- a/system/adb/adb_main.c +++ b/system/adb/adb_main.c @@ -39,7 +39,8 @@ * Public Functions ****************************************************************************/ -void adb_log_impl(FAR const char *func, int line, FAR const char *fmt, ...) +void adb_log_impl(int priority, FAR const char *func, int line, + FAR const char *fmt, ...) { struct va_format vaf; va_list ap; @@ -47,7 +48,24 @@ void adb_log_impl(FAR const char *func, int line, FAR const char *fmt, ...) va_start(ap, fmt); vaf.fmt = fmt; vaf.va = ≈ - syslog(LOG_ERR, "%s (%d): %pV", func, line, &vaf); + + switch (priority) + { + case ADB_INFO: + priority = LOG_INFO; + break; + case ADB_ERR: + priority = LOG_ERR; + break; + case ADB_WARN: + priority = LOG_WARNING; + break; + default: + priority = LOG_INFO; + break; + } + + syslog(priority, "%s (%d): %pV", func, line, &vaf); va_end(ap); } diff --git a/system/adb/logcat_service.c b/system/adb/logcat_service.c index 677170705cc..6dc54048406 100644 --- a/system/adb/logcat_service.c +++ b/system/adb/logcat_service.c @@ -126,7 +126,7 @@ static void logcat_on_data_available(uv_poll_t * handle, if (status) { - adb_log("status error %d\n", status); + adb_err("status error %d\n", status); /* Fatal error, stop service */ @@ -139,7 +139,7 @@ static void logcat_on_data_available(uv_poll_t * handle, ret = read(fd, ap->p.data, CONFIG_ADBD_PAYLOAD_SIZE); if (ret < 0) { - adb_log("frame read failed %d %d\n", ret, errno); + adb_err("frame read failed %d %d\n", ret, errno); if (errno == EAGAIN) { /* TODO this should never happen */ @@ -198,7 +198,7 @@ adb_service_t * logcat_service(adb_client_t *client, const char *params) if (ret < 0) { - adb_log("failed to open %s (%d)\n", CONFIG_SYSLOG_DEVPATH, errno); + adb_err("failed to open %s (%d)\n", CONFIG_SYSLOG_DEVPATH, errno); free(service); return NULL; }