summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChenjie Luo2017-04-27 18:49:09 -0500
committerChenjie Luo2017-04-28 19:30:25 -0500
commitfafea32468e0d59c1ce2eb845dd07a0b4e746cf0 (patch)
tree61797e8d7955cb3f00172e5968c191901a36643c /logd/LogListener.cpp
parent483d2f9a59bf4a5130e0a79306f30c25f675812c (diff)
downloadplatform-system-core-fafea32468e0d59c1ce2eb845dd07a0b4e746cf0.tar.gz
platform-system-core-fafea32468e0d59c1ce2eb845dd07a0b4e746cf0.tar.xz
platform-system-core-fafea32468e0d59c1ce2eb845dd07a0b4e746cf0.zip
Modularize logd.
Separates logd body into a static library liblogd and virtualize LogBuffer::log to be in a new interface class LogBufferInterface. User could have different implementation. Bug: 37756450 Test: liblog-unit-tests, logd-unit-tests and logcat-unit-tests with (b/37791296). Change-Id: I1504ff0e992744001b5a2e9abd45692d1318a152
Diffstat (limited to 'logd/LogListener.cpp')
-rw-r--r--logd/LogListener.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/logd/LogListener.cpp b/logd/LogListener.cpp
index dadc75f4c..709646e37 100644
--- a/logd/LogListener.cpp
+++ b/logd/LogListener.cpp
@@ -30,7 +30,7 @@
30#include "LogListener.h" 30#include "LogListener.h"
31#include "LogUtils.h" 31#include "LogUtils.h"
32 32
33LogListener::LogListener(LogBuffer* buf, LogReader* reader) 33LogListener::LogListener(LogBufferInterface* buf, LogReader* reader)
34 : SocketListener(getLogSocket(), false), logbuf(buf), reader(reader) { 34 : SocketListener(getLogSocket(), false), logbuf(buf), reader(reader) {
35} 35}
36 36
@@ -102,11 +102,14 @@ bool LogListener::onDataAvailable(SocketClient* cli) {
102 // NB: hdr.msg_flags & MSG_TRUNC is not tested, silently passing a 102 // NB: hdr.msg_flags & MSG_TRUNC is not tested, silently passing a
103 // truncated message to the logs. 103 // truncated message to the logs.
104 104
105 if (logbuf->log((log_id_t)header->id, header->realtime, cred->uid, 105 if (logbuf != nullptr) {
106 cred->pid, header->tid, msg, 106 int res = logbuf->log(
107 ((size_t)n <= USHRT_MAX) ? (unsigned short)n : USHRT_MAX) >= 107 (log_id_t)header->id, header->realtime, cred->uid, cred->pid,
108 0) { 108 header->tid, msg,
109 reader->notifyNewLog(); 109 ((size_t)n <= USHRT_MAX) ? (unsigned short)n : USHRT_MAX);
110 if (res > 0 && reader != nullptr) {
111 reader->notifyNewLog();
112 }
110 } 113 }
111 114
112 return true; 115 return true;