aosp12/system/logging/logd
hcl 7be3fd486c init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
..
doc_images init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
fuzz init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
.clang-format init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
Android.bp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
ChattyLogBuffer.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
ChattyLogBuffer.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
ChattyLogBufferTest.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
CommandListener.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
CommandListener.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
CompressionEngine.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
CompressionEngine.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogAudit.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogAudit.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogBuffer.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogBufferElement.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogBufferElement.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogBufferTest.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogBufferTest.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogKlog.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogKlog.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogListener.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogListener.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogPermissions.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogPermissions.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogReader.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogReader.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogReaderList.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogReaderList.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogReaderThread.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogReaderThread.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogSize.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogSize.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogStatistics.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogStatistics.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogTags.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogTags.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogUtils.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogWriter.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogdLock.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LogdLock.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
OWNERS init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
PkgIds.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
PruneList.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
PruneList.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
README.auditd init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
README.compression.md init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
README.property init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
README.replay.md init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
RecordedLogMessage.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
RecordingLogBuffer.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
RecordingLogBuffer.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
ReplayMessages.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
SerializedData.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
SerializedFlushToState.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
SerializedFlushToState.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
SerializedFlushToStateTest.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
SerializedLogBuffer.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
SerializedLogBuffer.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
SerializedLogBufferTest.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
SerializedLogChunk.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
SerializedLogChunk.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
SerializedLogChunkTest.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
SerializedLogEntry.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
SimpleLogBuffer.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
SimpleLogBuffer.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
auditctl.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
device_test_config.xml init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
event.logtags init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
libaudit.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
libaudit.h init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
logd.rc init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
logd_test.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
logtagd.rc init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
main.cpp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00

README.replay.md

logd can record and replay log messages for offline analysis.

Recording Messages

logd has a RecordingLogBuffer buffer that records messages to /data/misc/logd/recorded-messages. It stores messages in memory until that file is accessible, in order to capture all messages since the beginning of boot. It is only meant for logging developers to use and must be manually enabled in by adding RecordingLogBuffer.cpp to Android.bp and setting log_buffer = new SimpleLogBuffer(&reader_list, &log_tags, &log_statistics); in main.cpp.

Recording messages may delay the Log() function from completing and it is highly recommended to make the logd socket in liblog blocking, by removing SOCK_NONBLOCK from the socket() call in liblog/logd_writer.cpp.

Replaying Messages

Recorded messages can be replayed offline with the replay_messages tool. It runs on host and device and supports the following options:

  1. interesting - this prints 'interesting' statistics for each of the log buffer types (simple, chatty, serialized). The statistics are:
    1. Log Entry Count
    2. Size (the uncompressed size of the log messages in bytes)
    3. Overhead (the total cost of the log messages in memory in bytes)
    4. Range (the range of time that the logs cover in seconds)
  2. memory_usage BUFFER_TYPE - this prints the memory usage (sum of private dirty pages of the replay_messages process). Note that the input file is mmap()'ed as RO/Shared so it does not appear in these dirty pages, and a baseline is taken before allocating the log buffers, so only their contributions are measured. The tool outputs the memory usage every 100,000 messages.
  3. latency BUFFER_TYPE - this prints statistics of the latency of the Log() function for the given buffer type. It specifically prints the 1st, 2nd, and 3rd quartiles; the 95th, 99th, and 99.99th percentiles; and the maximum latency.
  4. print_logs BUFFER_TYPE [buffers] [print_point] - this prints the logs as processed by the given buffer_type from the buffers specified by buffers starting after the number of logs specified by print_point have been logged. This acts as if a user called logcat immediately after the specified logs have been logged, which is particularly useful since it will show the chatty pruning messages at that point. It additionally prints the statistics from logcat -S after the logs. buffers is a comma separated list of the numeric buffer id values from <android/log.h>. For example, 0,1,3 represents the main, radio, and system buffers. It can can also be all. print_point is an positive integer. If it is unspecified, logs are printed after the entire input file is consumed.
  5. nothing BUFFER_TYPE - this does nothing other than read the input file and call Log() for the given buffer type. This is used for profiling CPU usage of strictly the log buffer.