Commit graph

6 commits

Author SHA1 Message Date
Tom Cherry
283c9a1c00 logd: remove SocketClient from LogBuffer and LogBufferElement
In the future, we'll want to be able to write to outputs that are not
necessarily a libsysutils SocketClient, for example host tests of
LogBuffer.  Therefore, we add a LogWriter class to be used instead of
SocketClient.

Test: logging unit tests
Change-Id: I4385be65e14e83a635691a7ba79e9bf060e49484
2020-05-14 19:53:45 -07:00
Tom Cherry
d5b3838dbc logd: make LogBuffer an interface
We may use different implementations of LogBuffer in the future, so we
make it interface and create a concrete ChattyLogBuffer class that
implements it.

Test: logging unit tests
Change-Id: I5731d6404640664c9acc26b7c677dff3110c6a11
2020-05-12 15:39:19 -07:00
Tom Cherry
68630a0dbe logd: refactor LastLogTimes a bit
There's still plenty of work that can be done here, particularly
re-doing the locking so each LogReaderThread does not mutually exclude
the others, but that's out of the scope here.

This change primarily removes the public 'mTimes' from LogBuffer and
creates a new LogReaderList class instead.  It would have merged this
into LogReader, but that creates a circular dependency.

This change also removes the need to reference LogReader or
LogReaderList from LogAudit, LogKLog, and LogListener, instead relying
on LogBuffer()::log() to call LogReaderList::NotifyNewLog().

Test: logging unit tests
Change-Id: Ia874b57a9ec1254af1295bfa6f7af2f92a75755b
2020-05-12 15:39:11 -07:00
Tom Cherry
cef47bb38c logd: start cleaning up LogReaderThread
1) We can use real member functions with std::thread and
   std::function, so use those instead of the 'me' pointer.
2) Don't expose member variables directly.
3) Rename and document member variables, since all of their references
   are being touched anyway.

Test: logging unit tests
Change-Id: I9a357a3ea8691433d58687c95356b984b83e9c36
2020-05-04 17:44:52 -07:00
Tom Cherry
320f5968da logd: use std::function and lambdas where appropriate
Test: logging unit tests
Change-Id: I7cfc63937b5dadb5547c4661ca2f5204d7b4a174
2020-05-04 17:37:14 -07:00
Tom Cherry
6ec71e9253 logd: rename LogTimes -> LogReaderThread
LogTimes has evolved from being simply a store of the last timestamp
that each reader has read to being a class representing an individual
reader thread, including the thread function, so name it
appropriately.

Test: logging unit tests
Change-Id: I6914824376a6ff1f7509e657fa4dc044ead62954
2020-05-04 17:37:08 -07:00
Renamed from logd/LogTimes.cpp (Browse further)