diff options
author | Dan Albert <danalbert@google.com> | 2015-04-02 10:32:44 -0700 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2015-04-03 10:41:59 -0700 |
commit | c7aadc49d323df9753744617d8951e1e3ff48843 (patch) | |
tree | 6d2c41265676bed20c242cc147bc6e9c05393857 /liblog | |
parent | 7ab2c78ee9a7df21d149b6c5228f9d0fccb066e0 (diff) | |
download | system_core-c7aadc49d323df9753744617d8951e1e3ff48843.zip system_core-c7aadc49d323df9753744617d8951e1e3ff48843.tar.gz system_core-c7aadc49d323df9753744617d8951e1e3ff48843.tar.bz2 |
Share log writing code.
__android_log_write() was just a special form of
__android_log_buf_write that used a default log ID and set the abort
message for fatal messages. Presumably the latter was intended to be
set for __android_log_buf_write as well.
Change-Id: I51cff7561a2754676b2088d95fa4f4505ac3c3c2
Diffstat (limited to 'liblog')
-rw-r--r-- | liblog/logd_write.c | 44 | ||||
-rw-r--r-- | liblog/logd_write_kern.c | 40 |
2 files changed, 12 insertions, 72 deletions
diff --git a/liblog/logd_write.c b/liblog/logd_write.c index dfe34d1..c62a246 100644 --- a/liblog/logd_write.c +++ b/liblog/logd_write.c @@ -356,43 +356,7 @@ static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr) int __android_log_write(int prio, const char *tag, const char *msg) { - struct iovec vec[3]; - log_id_t log_id = LOG_ID_MAIN; - char tmp_tag[32]; - - if (!tag) - tag = ""; - - /* XXX: This needs to go! */ - if (!strcmp(tag, "HTC_RIL") || - !strncmp(tag, "RIL", 3) || /* Any log tag with "RIL" as the prefix */ - !strncmp(tag, "IMS", 3) || /* Any log tag with "IMS" as the prefix */ - !strcmp(tag, "AT") || - !strcmp(tag, "GSM") || - !strcmp(tag, "STK") || - !strcmp(tag, "CDMA") || - !strcmp(tag, "PHONE") || - !strcmp(tag, "SMS")) { - log_id = LOG_ID_RADIO; - /* Inform third party apps/ril/radio.. to use Rlog or RLOG */ - snprintf(tmp_tag, sizeof(tmp_tag), "use-Rlog/RLOG-%s", tag); - tag = tmp_tag; - } - -#if __BIONIC__ - if (prio == ANDROID_LOG_FATAL) { - android_set_abort_message(msg); - } -#endif - - vec[0].iov_base = (unsigned char *) &prio; - vec[0].iov_len = 1; - vec[1].iov_base = (void *) tag; - vec[1].iov_len = strlen(tag) + 1; - vec[2].iov_base = (void *) msg; - vec[2].iov_len = strlen(msg) + 1; - - return write_to_log(log_id, vec, 3); + return __android_log_buf_write(LOG_ID_MAIN, prio, tag, msg); } int __android_log_buf_write(int bufID, int prio, const char *tag, const char *msg) @@ -420,6 +384,12 @@ int __android_log_buf_write(int bufID, int prio, const char *tag, const char *ms tag = tmp_tag; } +#if __BIONIC__ + if (prio == ANDROID_LOG_FATAL) { + android_set_abort_message(msg); + } +#endif + vec[0].iov_base = (unsigned char *) &prio; vec[0].iov_len = 1; vec[1].iov_base = (void *) tag; diff --git a/liblog/logd_write_kern.c b/liblog/logd_write_kern.c index ca63067..8742b34 100644 --- a/liblog/logd_write_kern.c +++ b/liblog/logd_write_kern.c @@ -139,41 +139,7 @@ static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr) int __android_log_write(int prio, const char *tag, const char *msg) { - struct iovec vec[3]; - log_id_t log_id = LOG_ID_MAIN; - char tmp_tag[32]; - - if (!tag) - tag = ""; - - /* XXX: This needs to go! */ - if (!strcmp(tag, "HTC_RIL") || - !strncmp(tag, "RIL", 3) || /* Any log tag with "RIL" as the prefix */ - !strncmp(tag, "IMS", 3) || /* Any log tag with "IMS" as the prefix */ - !strcmp(tag, "AT") || - !strcmp(tag, "GSM") || - !strcmp(tag, "STK") || - !strcmp(tag, "CDMA") || - !strcmp(tag, "PHONE") || - !strcmp(tag, "SMS")) { - log_id = LOG_ID_RADIO; - /* Inform third party apps/ril/radio.. to use Rlog or RLOG */ - snprintf(tmp_tag, sizeof(tmp_tag), "use-Rlog/RLOG-%s", tag); - tag = tmp_tag; - } - - if (prio == ANDROID_LOG_FATAL) { - android_set_abort_message(msg); - } - - vec[0].iov_base = (unsigned char *) &prio; - vec[0].iov_len = 1; - vec[1].iov_base = (void *) tag; - vec[1].iov_len = strlen(tag) + 1; - vec[2].iov_base = (void *) msg; - vec[2].iov_len = strlen(msg) + 1; - - return write_to_log(log_id, vec, 3); + return __android_log_buf_write(LOG_ID_MAIN, prio, tag, msg); } int __android_log_buf_write(int bufID, int prio, const char *tag, const char *msg) @@ -201,6 +167,10 @@ int __android_log_buf_write(int bufID, int prio, const char *tag, const char *ms tag = tmp_tag; } + if (prio == ANDROID_LOG_FATAL) { + android_set_abort_message(msg); + } + vec[0].iov_base = (unsigned char *) &prio; vec[0].iov_len = 1; vec[1].iov_base = (void *) tag; |