summaryrefslogtreecommitdiffstats
path: root/liblog
diff options
context:
space:
mode:
authorStefan Lafon <stlafon@google.com>2017-08-24 20:14:06 -0700
committerYao Chen <yaochen@google.com>2017-11-14 16:20:00 -0800
commit701a0658e6241589a643c3dcab483d3999a4c8e8 (patch)
treeec8b88391e483b0bff7dc50b4549fa025f62f969 /liblog
parent21d3840eb39291bbc59f0dc5a33fc58b152994fe (diff)
downloadsystem_core-701a0658e6241589a643c3dcab483d3999a4c8e8.tar.gz
system_core-701a0658e6241589a643c3dcab483d3999a4c8e8.tar.bz2
system_core-701a0658e6241589a643c3dcab483d3999a4c8e8.zip
Create stats buffer in logd.
Bug: 69323063 Test: ran unit tests. Change-Id: Icfb827ab4674172c26b4bbfe1a9b3bffc03dc24b (cherry picked from commit 1b1b6f50c78d88e3256a5e13559d92fbb6d1c8fe)
Diffstat (limited to 'liblog')
-rw-r--r--liblog/include/log/log.h2
-rw-r--r--liblog/include/log/log_id.h5
-rw-r--r--liblog/log_event_list.c6
-rw-r--r--liblog/logger_name.c3
-rw-r--r--liblog/logger_write.c13
5 files changed, 24 insertions, 5 deletions
diff --git a/liblog/include/log/log.h b/liblog/include/log/log.h
index d01708d8b..3813e6e32 100644
--- a/liblog/include/log/log.h
+++ b/liblog/include/log/log.h
@@ -95,6 +95,8 @@ int __android_log_btwrite(int32_t tag, char type, const void* payload,
size_t len);
int __android_log_bswrite(int32_t tag, const char* payload);
+int __android_log_stats_bwrite(int32_t tag, const void* payload, size_t len);
+
#define android_bWriteLog(tag, payload, len) \
__android_log_bwrite(tag, payload, len)
#define android_btWriteLog(tag, type, payload, len) \
diff --git a/liblog/include/log/log_id.h b/liblog/include/log/log_id.h
index 7bfa2770b..c44f5a2eb 100644
--- a/liblog/include/log/log_id.h
+++ b/liblog/include/log/log_id.h
@@ -31,8 +31,9 @@ typedef enum log_id {
LOG_ID_EVENTS = 2,
LOG_ID_SYSTEM = 3,
LOG_ID_CRASH = 4,
- LOG_ID_SECURITY = 5,
- LOG_ID_KERNEL = 6, /* place last, third-parties can not use it */
+ LOG_ID_STATS = 5,
+ LOG_ID_SECURITY = 6,
+ LOG_ID_KERNEL = 7, /* place last, third-parties can not use it */
LOG_ID_MAX
} log_id_t;
diff --git a/liblog/log_event_list.c b/liblog/log_event_list.c
index 59ea5ef13..a59cb8738 100644
--- a/liblog/log_event_list.c
+++ b/liblog/log_event_list.c
@@ -301,7 +301,7 @@ LIBLOG_ABI_PUBLIC int android_log_write_list(android_log_context ctx,
const char* msg;
ssize_t len;
- if ((id != LOG_ID_EVENTS) && (id != LOG_ID_SECURITY)) {
+ if ((id != LOG_ID_EVENTS) && (id != LOG_ID_SECURITY) && (id != LOG_ID_STATS)) {
return -EINVAL;
}
@@ -326,7 +326,9 @@ LIBLOG_ABI_PUBLIC int android_log_write_list(android_log_context ctx,
}
return (id == LOG_ID_EVENTS)
? __android_log_bwrite(context->tag, msg, len)
- : __android_log_security_bwrite(context->tag, msg, len);
+ : ((id == LOG_ID_STATS)
+ ? __android_log_stats_bwrite(context->tag, msg, len)
+ : __android_log_security_bwrite(context->tag, msg, len));
}
LIBLOG_ABI_PRIVATE int android_log_write_list_buffer(android_log_context ctx,
diff --git a/liblog/logger_name.c b/liblog/logger_name.c
index a5a83e05a..479bbfeec 100644
--- a/liblog/logger_name.c
+++ b/liblog/logger_name.c
@@ -22,12 +22,13 @@
/* In the future, we would like to make this list extensible */
static const char* LOG_NAME[LOG_ID_MAX] = {
- /* clang-format off */
+ /* clang-format off */
[LOG_ID_MAIN] = "main",
[LOG_ID_RADIO] = "radio",
[LOG_ID_EVENTS] = "events",
[LOG_ID_SYSTEM] = "system",
[LOG_ID_CRASH] = "crash",
+ [LOG_ID_STATS] = "stats",
[LOG_ID_SECURITY] = "security",
[LOG_ID_KERNEL] = "kernel",
/* clang-format on */
diff --git a/liblog/logger_write.c b/liblog/logger_write.c
index 84feb206b..589ce8429 100644
--- a/liblog/logger_write.c
+++ b/liblog/logger_write.c
@@ -546,6 +546,19 @@ LIBLOG_ABI_PUBLIC int __android_log_bwrite(int32_t tag, const void* payload,
return write_to_log(LOG_ID_EVENTS, vec, 2);
}
+LIBLOG_ABI_PUBLIC int __android_log_stats_bwrite(int32_t tag,
+ const void* payload,
+ size_t len) {
+ struct iovec vec[2];
+
+ vec[0].iov_base = &tag;
+ vec[0].iov_len = sizeof(tag);
+ vec[1].iov_base = (void*)payload;
+ vec[1].iov_len = len;
+
+ return write_to_log(LOG_ID_STATS, vec, 2);
+}
+
LIBLOG_ABI_PUBLIC int __android_log_security_bwrite(int32_t tag,
const void* payload,
size_t len) {