Skip to content

Commit

Permalink
adb: add adb log level
Browse files Browse the repository at this point in the history
Signed-off-by: zhangyuan21 <[email protected]>
  • Loading branch information
zhangyuan21 committed Aug 9, 2023
1 parent 4d2fb8a commit fb7f605
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion system/adb/adb_banner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 20 additions & 2 deletions system/adb/adb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,33 @@
* 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;

va_start(ap, fmt);
vaf.fmt = fmt;
vaf.va = &ap;
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);
}

Expand Down
6 changes: 3 additions & 3 deletions system/adb/logcat_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand All @@ -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 */
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit fb7f605

Please sign in to comment.