Remove __android_log_event_list and the reader aspect of android_log_event_list

One user of each, dubious API, remove it while we work on a new one.

Test: build
Change-Id: If422246226addaf873dc2af32553fad3a5182089
This commit is contained in:
Tom Cherry 2019-01-16 13:57:31 -08:00
parent df8063d045
commit c2ea6e7c39
4 changed files with 27 additions and 61 deletions

View file

@ -109,8 +109,6 @@ int android_log_destroy(android_log_context* ctx);
/* android_log_list C++ helpers */
extern "C++" {
class android_log_event_list {
friend class __android_log_event_list;
private:
android_log_context ctx;
int ret;
@ -122,10 +120,6 @@ class android_log_event_list {
explicit android_log_event_list(int tag) : ret(0) {
ctx = create_android_logger(static_cast<uint32_t>(tag));
}
explicit android_log_event_list(log_msg& log_msg) : ret(0) {
ctx = create_android_log_parser(log_msg.msg() + sizeof(uint32_t),
log_msg.entry.len - sizeof(uint32_t));
}
~android_log_event_list() {
android_log_destroy(&ctx);
}
@ -283,13 +277,6 @@ class android_log_event_list {
if (retval < 0) ret = retval;
return ret >= 0;
}
android_log_list_element read() {
return android_log_read_next(ctx);
}
android_log_list_element peek() {
return android_log_peek_next(ctx);
}
};
}
#endif

View file

@ -150,37 +150,6 @@ bool __android_logger_valid_buffer_size(unsigned long value);
/* Retrieve the composed event buffer */
int android_log_write_list_buffer(android_log_context ctx, const char** msg);
#ifdef __cplusplus
#ifdef __class_android_log_event_list_defined
#ifndef __class_android_log_event_list_private_defined
#define __class_android_log_event_list_private_defined
/* android_log_context C++ helpers */
extern "C++" {
class __android_log_event_list : public android_log_event_list {
__android_log_event_list(const android_log_event_list&) = delete;
void operator=(const __android_log_event_list&) = delete;
public:
explicit __android_log_event_list(int tag) : android_log_event_list(tag) {
}
explicit __android_log_event_list(log_msg& log_msg)
: android_log_event_list(log_msg) {
}
operator std::string() {
if (ret) return std::string("");
const char* cp = nullptr;
ssize_t len = android_log_write_list_buffer(ctx, &cp);
if (len < 0) ret = len;
if (!cp || (len <= 0)) return std::string("");
return std::string(cp, len);
}
};
}
#endif
#endif
#endif
#if defined(__cplusplus)
}
#endif

View file

@ -51,10 +51,6 @@ class stats_event_list {
explicit stats_event_list(int tag) : ret(0) {
ctx = create_android_logger(static_cast<uint32_t>(tag));
}
explicit stats_event_list(log_msg& log_msg) : ret(0) {
ctx = create_android_log_parser(log_msg.msg() + sizeof(uint32_t),
log_msg.entry.len - sizeof(uint32_t));
}
~stats_event_list() { android_log_destroy(&ctx); }
int close() {
@ -251,9 +247,6 @@ class stats_event_list {
}
return ret >= 0;
}
android_log_list_element read() { return android_log_read_next(ctx); }
android_log_list_element peek() { return android_log_peek_next(ctx); }
};
#endif

View file

@ -30,6 +30,7 @@
#include <android-base/file.h>
#include <android-base/macros.h>
#include <android-base/scopeguard.h>
#include <android-base/stringprintf.h>
#include <log/log_event_list.h>
#include <log/log_properties.h>
@ -38,6 +39,8 @@
#include "LogTags.h"
#include "LogUtils.h"
using android::base::make_scope_guard;
static LogTags* logtags;
const char LogTags::system_event_log_tags[] = "/system/etc/event-log-tags";
@ -316,27 +319,29 @@ void LogTags::ReadPersistEventLogTags() {
std::string Format;
android_log_list_element elem;
{
android_log_event_list ctx(log_msg);
elem = ctx.read();
auto ctx = create_android_log_parser(log_msg.msg() + sizeof(uint32_t),
log_msg.entry.len - sizeof(uint32_t));
auto guard = make_scope_guard([&ctx]() { android_log_destroy(&ctx); });
elem = android_log_read_next(ctx);
if (elem.type != EVENT_TYPE_LIST) {
continue;
}
elem = ctx.read();
elem = android_log_read_next(ctx);
if (elem.type != EVENT_TYPE_INT) {
continue;
}
Tag = elem.data.int32;
elem = ctx.read();
elem = android_log_read_next(ctx);
if (elem.type != EVENT_TYPE_STRING) {
continue;
}
Name = std::string(elem.data.string, elem.len);
elem = ctx.read();
elem = android_log_read_next(ctx);
if (elem.type != EVENT_TYPE_STRING) {
continue;
}
Format = std::string(elem.data.string, elem.len);
elem = ctx.read();
elem = android_log_read_next(ctx);
}
if ((elem.type != EVENT_TYPE_LIST_STOP) || !elem.complete) continue;
@ -524,10 +529,22 @@ void LogTags::WritePmsgEventLogTags(uint32_t tag, uid_t uid) {
tag2format_const_iterator iform = tag2format.find(tag);
std::string Format = (iform != tag2format.end()) ? iform->second : "";
__android_log_event_list ctx(TAG_DEF_LOG_TAG);
ctx << tag << Name << Format;
std::string buffer(ctx);
if (buffer.length() <= 0) return; // unlikely
auto ctx = create_android_logger(TAG_DEF_LOG_TAG);
auto guard = make_scope_guard([&ctx]() { android_log_destroy(&ctx); });
if (android_log_write_int32(ctx, static_cast<int32_t>(tag) < 0) ||
android_log_write_string8_len(ctx, Name.c_str(), Name.size()) < 0 ||
android_log_write_string8_len(ctx, Format.c_str(), Format.size()) < 0) {
return;
}
const char* cp = nullptr;
ssize_t len = android_log_write_list_buffer(ctx, &cp);
if (len <= 0 || cp == nullptr) {
return;
}
std::string buffer(cp, len);
/*
* struct {