Mark Salyzyn | 46fef16 | 2016-07-07 09:24:51 -0700 | [diff] [blame] | 1 | # |
| 2 | # init scriptures for logcatd persistent logging. |
| 3 | # |
| 4 | # Make sure any property changes are only performed with /data mounted, after |
| 5 | # post-fs-data state because otherwise behavior is undefined. The exceptions |
| 6 | # are device adjustments for logcatd service properties (persist.* overrides |
Tian, Baofeng | 547ed6f | 2019-05-21 11:19:12 +0800 | [diff] [blame] | 7 | # notwithstanding) for logd.logpersistd.size logd.logpersistd.rotate_kbytes and |
| 8 | # logd.logpersistd.buffer. |
Mark Salyzyn | 46fef16 | 2016-07-07 09:24:51 -0700 | [diff] [blame] | 9 | |
| 10 | # persist to non-persistent trampolines to permit device properties can be |
| 11 | # overridden when /data mounts, or during runtime. |
Tian, Baofeng | 547ed6f | 2019-05-21 11:19:12 +0800 | [diff] [blame] | 12 | on property:persist.logd.logpersistd.count=* |
| 13 | # expect /init to report failure if property empty (default) |
| 14 | setprop persist.logd.logpersistd.size ${persist.logd.logpersistd.count} |
| 15 | |
Mark Salyzyn | 46fef16 | 2016-07-07 09:24:51 -0700 | [diff] [blame] | 16 | on property:persist.logd.logpersistd.size=* |
Mark Salyzyn | 46fef16 | 2016-07-07 09:24:51 -0700 | [diff] [blame] | 17 | setprop logd.logpersistd.size ${persist.logd.logpersistd.size} |
| 18 | |
Tian, Baofeng | 547ed6f | 2019-05-21 11:19:12 +0800 | [diff] [blame] | 19 | on property:persist.logd.logpersistd.rotate_kbytes=* |
Tian Baofeng | 87b6d86 | 2019-07-12 15:09:36 +0800 | [diff] [blame^] | 20 | setprop logd.logpersistd.rotate_kbytes ${persist.logd.logpersistd.rotate_kbytes} |
Mark Salyzyn | 46fef16 | 2016-07-07 09:24:51 -0700 | [diff] [blame] | 21 | |
| 22 | on property:persist.logd.logpersistd.buffer=* |
Mark Salyzyn | 46fef16 | 2016-07-07 09:24:51 -0700 | [diff] [blame] | 23 | setprop logd.logpersistd.buffer ${persist.logd.logpersistd.buffer} |
| 24 | |
Tom Cherry | 54951de | 2015-08-14 13:02:51 -0700 | [diff] [blame] | 25 | on property:persist.logd.logpersistd=logcatd |
Mark Salyzyn | 46fef16 | 2016-07-07 09:24:51 -0700 | [diff] [blame] | 26 | setprop logd.logpersistd logcatd |
| 27 | |
| 28 | # enable, prep and start logcatd service |
| 29 | on load_persist_props_action |
| 30 | setprop logd.logpersistd.enable true |
| 31 | |
| 32 | on property:logd.logpersistd.enable=true && property:logd.logpersistd=logcatd |
Tom Cherry | 54951de | 2015-08-14 13:02:51 -0700 | [diff] [blame] | 33 | # all exec/services are called with umask(077), so no gain beyond 0700 |
| 34 | mkdir /data/misc/logd 0700 logd log |
Tom Cherry | 54951de | 2015-08-14 13:02:51 -0700 | [diff] [blame] | 35 | start logcatd |
| 36 | |
Mark Salyzyn | 46fef16 | 2016-07-07 09:24:51 -0700 | [diff] [blame] | 37 | # stop logcatd service and clear data |
| 38 | on property:logd.logpersistd.enable=true && property:logd.logpersistd=clear |
| 39 | setprop persist.logd.logpersistd "" |
Mark Salyzyn | ee5724d | 2016-06-06 11:22:13 -0700 | [diff] [blame] | 40 | stop logcatd |
| 41 | # logd for clear of only our files in /data/misc/logd |
Mark Salyzyn | 46fef16 | 2016-07-07 09:24:51 -0700 | [diff] [blame] | 42 | exec - logd log -- /system/bin/logcat -c -f /data/misc/logd/logcat -n ${logd.logpersistd.size:-256} |
| 43 | setprop logd.logpersistd "" |
Mark Salyzyn | ee5724d | 2016-06-06 11:22:13 -0700 | [diff] [blame] | 44 | |
Mark Salyzyn | 46fef16 | 2016-07-07 09:24:51 -0700 | [diff] [blame] | 45 | # stop logcatd service |
| 46 | on property:logd.logpersistd=stop |
| 47 | setprop persist.logd.logpersistd "" |
Mark Salyzyn | ee5724d | 2016-06-06 11:22:13 -0700 | [diff] [blame] | 48 | stop logcatd |
Mark Salyzyn | 46fef16 | 2016-07-07 09:24:51 -0700 | [diff] [blame] | 49 | setprop logd.logpersistd "" |
Mark Salyzyn | ee5724d | 2016-06-06 11:22:13 -0700 | [diff] [blame] | 50 | |
Mark Salyzyn | 46fef16 | 2016-07-07 09:24:51 -0700 | [diff] [blame] | 51 | on property:logd.logpersistd.enable=false |
| 52 | stop logcatd |
| 53 | |
| 54 | # logcatd service |
Tian, Baofeng | 547ed6f | 2019-05-21 11:19:12 +0800 | [diff] [blame] | 55 | 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} |
Tom Cherry | 54951de | 2015-08-14 13:02:51 -0700 | [diff] [blame] | 56 | class late_start |
| 57 | disabled |
| 58 | # logd for write to /data/misc/logd, log group for read from log daemon |
| 59 | user logd |
| 60 | group log |
Tom Cherry | cd7685a | 2015-09-21 14:25:34 -0700 | [diff] [blame] | 61 | writepid /dev/cpuset/system-background/tasks |
Mark Salyzyn | b5f3d34 | 2017-05-30 09:01:38 -0700 | [diff] [blame] | 62 | oom_score_adjust -600 |