From 00813a585a4dc5d34e6415e29731615313d4925a Mon Sep 17 00:00:00 2001 From: "Tian, Baofeng" Date: Tue, 21 May 2019 11:19:12 +0800 Subject: [PATCH] Logcatd: Add new properties control logcat file size and file count. Logcatd has capability to output logs to filesystem with certain size and certain file count, however file size is not configurable, fixed as 1024 kbytes, file count is configurable, but original property name didn't match the logcat parameter well. This patch add interface rotate_kbytes and count into logcatd.rc. rotate_kbytes used to control each logcat file size. count is another alias for logd.logpersistd.size to control file number. Bug: 133362078 Test: Can use logcat -r -n with configures Change-Id: I9954c9c125a4ab4e49310986f81c734bf8ee96b3 Signed-off-by: Tian, Baofeng Signed-off-by: Duan, YayongX --- logcat/logcatd.rc | 17 +++++++++++++++-- logd/README.property | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/logcat/logcatd.rc b/logcat/logcatd.rc index 07040b01d..25104eb63 100644 --- a/logcat/logcatd.rc +++ b/logcat/logcatd.rc @@ -4,10 +4,15 @@ # Make sure any property changes are only performed with /data mounted, after # post-fs-data state because otherwise behavior is undefined. The exceptions # are device adjustments for logcatd service properties (persist.* overrides -# notwithstanding) for logd.logpersistd.size and logd.logpersistd.buffer. +# notwithstanding) for logd.logpersistd.size logd.logpersistd.rotate_kbytes and +# logd.logpersistd.buffer. # persist to non-persistent trampolines to permit device properties can be # overridden when /data mounts, or during runtime. +on property:persist.logd.logpersistd.count=* + # expect /init to report failure if property empty (default) + setprop persist.logd.logpersistd.size ${persist.logd.logpersistd.count} + on property:persist.logd.logpersistd.size=256 setprop persist.logd.logpersistd.size "" setprop logd.logpersistd.size "" @@ -16,6 +21,14 @@ on property:persist.logd.logpersistd.size=* # expect /init to report failure if property empty (default) setprop logd.logpersistd.size ${persist.logd.logpersistd.size} +on property:persist.logd.logpersistd.rotate_kbytes=1024 + setprop persist.logd.logpersistd.rotate_kbytes "" + setprop logd.logpersistd.rotate_kbytes "" + +on property:persist.logd.logpersistd.rotate_kbytes=* + # expect /init to report failure if property empty (default) + setprop logd.logpersistd.rotate_kbytes ${persist.logd.logpersistd.rotate_kbytes} + on property:persist.logd.logpersistd.buffer=all setprop persist.logd.logpersistd.buffer "" setprop logd.logpersistd.buffer "" @@ -54,7 +67,7 @@ on property:logd.logpersistd.enable=false stop logcatd # logcatd service -service logcatd /system/bin/logcatd -L -b ${logd.logpersistd.buffer:-all} -v threadtime -v usec -v printable -D -f /data/misc/logd/logcat -r 1024 -n ${logd.logpersistd.size:-256} --id=${ro.build.id} +service logcatd /system/bin/logcatd -L -b ${logd.logpersistd.buffer:-all} -v threadtime -v usec -v printable -D -f /data/misc/logd/logcat -r ${logd.logpersistd.rotate_kbytes:-1024} -n ${logd.logpersistd.size:-256} --id=${ro.build.id} class late_start disabled # logd for write to /data/misc/logd, log group for read from log daemon diff --git a/logd/README.property b/logd/README.property index da5f96fb7..d2a2cbba4 100644 --- a/logd/README.property +++ b/logd/README.property @@ -17,10 +17,13 @@ logd.logpersistd string persist Enable logpersist daemon, "logcatd" Responds to logcatd, clear and stop. logd.logpersistd.buffer persist logpersistd buffers to collect logd.logpersistd.size persist logpersistd size in MB +logd.logpersistd.rotate_kbytes persist logpersistd outout file size in KB. persist.logd.logpersistd string Enable logpersist daemon, "logcatd" turns on logcat -f in logd context. persist.logd.logpersistd.buffer all logpersistd buffers to collect persist.logd.logpersistd.size 256 logpersistd size in MB +persist.logd.logpersistd.count 256 sets max number of rotated logs to . +persist.logd.logpersistd.rotate_kbytes 1024 logpersistd output file size in KB persist.logd.size number ro Global default size of the buffer for all log ids at initial startup, at runtime use: logcat -b all -G