Loading liblog/include/log/log_event_list.h +0 −13 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); } Loading Loading @@ -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 Loading liblog/include/private/android_logger.h +0 −31 Original line number Diff line number Diff line Loading @@ -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 libstats/include/stats_event_list.h +0 −7 Original line number Diff line number Diff line Loading @@ -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() { Loading Loading @@ -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 Loading logd/LogTags.cpp +27 −10 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -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"; Loading Loading @@ -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; Loading Loading @@ -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 { Loading Loading
liblog/include/log/log_event_list.h +0 −13 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); } Loading Loading @@ -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 Loading
liblog/include/private/android_logger.h +0 −31 Original line number Diff line number Diff line Loading @@ -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
libstats/include/stats_event_list.h +0 −7 Original line number Diff line number Diff line Loading @@ -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() { Loading Loading @@ -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 Loading
logd/LogTags.cpp +27 −10 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -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"; Loading Loading @@ -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; Loading Loading @@ -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 { Loading