Commit graph

209 commits

Author SHA1 Message Date
Mark Salyzyn
c91c4446a6 resolve merge conflicts of 5f6dbd9 to nyc-mr1-dev-plus-aosp
Change-Id: Ia85ca9ea4c38d270229af394c351b7b31ea2057e
2016-08-08 13:10:35 -07:00
Mark Salyzyn
8065220686 Merge "logcatd: logpersist.start more descriptive warning" am: dad158f3a1 am: 2c1322f751
am: dbfe0a1abe

Change-Id: I460f84979b743a341de4265f398b53cea8724e49
2016-08-08 18:36:12 +00:00
Mark Salyzyn
ad5e411608 logcat: -d, -t or -L, along with -f, do not background
Specifically logcatd with exec logcat -L needs to be foreground
process cgroup as it is spawned and can block init progress. Makes
sense generally to only set background cgroup when we are taking
continuous content, and we are pushing that content to a set of
logrotate files.

Rename setupOutput to setupOutputAndSchedulingPolicy to more
clearly indicate its purpose.

Bug: 30630936
Bug: 30612424
Bug: 28788401
Change-Id: I628d590a42a53a6b448ecd0af53d6d1edf7bbb0e
2016-08-08 10:20:22 -07:00
Mark Salyzyn
31961061d5 logcat: lastLogTime only two most recent files
Scaling issues if -f logrotation is specified and there are a lot of
log files to process in lastLogTime, focus on only the last two log
files. This will cover the situation where we have recently rotated
the logs and the last file is missing or empty.

This also alters monotonic processing as well as it used to focus on
only the last file; the danger being doubled now if the pair covers
more than one reboot when filling in missing content with logcat -L.
Problem was always there with one log file, but now we handle if
rotation happened recently. A fair tradeoff for KISS.

Bug: 30630936
Bug: 30612424
Bug: 28788401
Change-Id: I1c13b94e88f5edc08ecef52d407e296874ca5807
2016-08-08 10:20:22 -07:00
Mark Salyzyn
9b35df6517 logcatd: Add --id=${ro.build.id}
If a new build lands, this will automatically clear out old
logs in /data/misc/logd/ that may no longer be relevant.

Bug: 30591615
Change-Id: Iecf61bb2a4928ce4b2e8cc6a3b122b7ae598d268
2016-08-08 10:20:22 -07:00
Mark Salyzyn
2e5b71873c logcatd: fix up logpersist.cat to filter out signature file
Simple filter for no suffix, or a numerical suffix. toybox
grep did not handle a more robust regex, so we opted for
kiss in order to remove the .id suffix from consideration.

Bug: 30591615
Change-Id: I5b1c929d3e69c1ae39af95ae44a69f7b55e969ed
2016-08-08 10:20:22 -07:00
Mark Salyzyn
02687e75b0 logcat: add --id=<id> for -f option
Clear file rotate content if id signature changes. This allows
logcatd to detect change of property ro.build.id to reset the
recorded data. The id is stored in the the -f filespec as
<filespec>.id.

If the id file is missing or unreadable, do not clear. Allow an
API where chmod 0 to the id file blocks this feature. Does not
work for root.

Add logcat.logrotate_id gTest.

Bug: 30591615
Change-Id: I895749ca7c6d4af57ec57f058a29d8e3af2f8b27
2016-08-08 10:19:48 -07:00
Mark Salyzyn
5b1a538fc8 logcat: switch to android::base::StringPrintf
asprintf should be replaced with StringPrintf, solves
a memory leak issue because of exiting scope.

Bug: 30591615
Change-Id: I88644cc27946ba4f25d4539420199c6f40df1bfa
2016-08-08 10:03:14 -07:00
Mark Salyzyn
452eaf7d5b logcatd: logpersist.start more descriptive warning
"killing Settings" is meaningless without context, we are killing the
Settings application to pull in new values, so make this clearer!

Change-Id: Ice0b950040bd05dcd49b7315def4dac3dd93eb27
2016-08-08 10:03:05 -07:00
Ruchi Kandoi
dc4c1654b5 logd: logcat -L takes longer causing vold to timeout. am: 90a3f81c9e
am: 366513fc3f

Change-Id: Iab79f34aa6655295672fdd53dca7cef58b2574ee
2016-08-03 22:21:44 +00:00
Ruchi Kandoi
90a3f81c9e logd: logcat -L takes longer causing vold to timeout.
Temporary fix to prevent device from getting stuck at boot.

Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Bug: 28788401
Bug: 30041146
Bug: 30612424
Bug: 30630936
Change-Id: Ie4246fc3c9eb7a3af2cb909546811c85997515da
2016-08-03 20:27:02 +00:00
Mark Salyzyn
6a7bfd8749 logcatd: logpersist.start to enable logd service if disabled
Bug: 28936216
Change-Id: I2f2878f138be6675bf00bd638df2bdd690a1fae5
2016-07-21 14:19:39 -07:00
Mark Salyzyn
df5d12850a logcatd: trampoline persist.logd.logpersistd to logd.logpersistd
(cherry pick from 2591d483c8)

Best practices so that device can set logd.logpersistd properties.
Values can be overriden with trampolines for persist.logd.logpersistd
values except as designed for empty content to keep out of the way.

This allows us to set logd.logpersistd* for a non-persistent collection
that does not survive a reboot, and to use persist.logd.logpersistd*
for persistent collection that does survive a reboot.

Added logd.logpersistd.enable to gate when logpersist service can be
run allowing the properties to be adjusted safely prior to this state
as is the case for device property.

NB: /init will complain when trying to trampoline an empty property,
    this is acceptable for functionality, but may be considered
    annoying from the logging perspective.

Bug: 28788401
Bug: 28813587
Bug: 28936216
Bug: 29831823
Change-Id: I97317e8eedfae4daa8e3ef39e64e7c5c23d8b573
2016-07-19 11:13:14 -07:00
Mark Salyzyn
2d737011d6 logcatd: add stop and clear actions
(cherry pick from commit cd5118bf1e)

- add stop and clear (and stop) actions to logcatd.rc
- use stop and clear actions in logpersist script

Bug: 28788401
Bug: 28813587
Bug: 28936216
Change-Id: Id05118fb51e40609fd7b3a934cf9302f67ef6d1d
2016-07-19 11:13:14 -07:00
Mark Salyzyn
befa79d7e0 logcatd: Do not su for setprop
(cherry pick from commit 8d2a65572b)

sepolicy now permits setting persist.logd.logpersistd in shell

Bug: 28788401
Bug: 28813587
Bug: 28936216
Change-Id: Ieed50eae0f91afa5b0c0e4ade7a71922c4b7ef93
2016-07-19 11:13:14 -07:00
Mark Salyzyn
7545b471a2 logcat: allow comma-separate list of buffers
(cherry pick from commit 4517773296)

- Add parsing to support comma+ separated list of buffers.
- Move get_size test into a standalone get_groups function
- add some additional tests for this feature, leveraging
  get_groups to confirm buffer selection.

Bug: 28120456
Bug: 28788401
Bug: 28813587
Change-Id: I0b42736c08cf4b2a435cb74cda540dc163a26bd1
2016-07-19 11:13:14 -07:00
Mark Salyzyn
c869959d62 logcat: clear when specifying file output
(cherry pick from commit b7d059bb2f)

If -c and -f are both specified, clear the files rather
than notifying the logger to clear its data. The -f then
acts like a switch between clearing the in-memory log
data, or the on-disk logrotate data.

Bug: 28788401
Bug: 28813587
Bug: 28936216
Change-Id: Ib1d1fb46ea09f81a2fd9bebb6c8f0f9f2355f6e8
2016-07-19 11:13:14 -07:00
Mark Salyzyn
3f6777a3dd logcat: Adjust help to make it more meaningful
(cherry pick from commit 378f4745a2)

It is not clear about the long option aliases, list
them comma separate first for clarity. Squash lines
of help content if possible. Lock to 3 indents, one
for options, another for text on same line as options
and another for next line or continuation.

Bug: 28120456
Bug: 28788401
Bug: 28813587
Change-Id: I5331acde3ac0fd3b87f6699ba108f6cef46a1563
2016-07-19 11:13:10 -07:00
Mark Salyzyn
515f091f5e logpersist: incorporate size and buffer tunables
- Add hidden -n and -b flags that propagate to the underlying
  logcat command. Publish aliases in help as --size and --buffer.
- Add --clear for start command so it clears before starting
- shell script bloating up to deal with option validation and
  provide ERROR: and WARNING: advice.

ToDo:

- Deprecate shell script and replace with Eng and Userdebug
  only Developer Options, before it becomes too powerful
  or bloated to force us to rewrite an expendable like this
  into C++.

Bug: 28120456
Bug: 28788401
Change-Id: I0dff8acaa1e5c929454760cfa2801924956bc25d
2016-07-13 23:53:54 +00:00
Thierry Strudel
aa3a56539d Revert "logd: logcat -L takes longer causing vold to timeout."
This reverts commit c1b26acae2.

Bug: 28788401
Change-Id: I415530deb7587d1068f42971762b418b0524663c
2016-07-13 23:53:10 +00:00
Mark Salyzyn
2591d483c8 logcatd: trampoline persist.logd.logpersistd to logd.logpersistd
Best practices so that device can set logd.logpersistd properties.
Values can be overriden with trampolines for persist.logd.logpersistd
values except as designed for empty content to keep out of the way.

This allows us to set logd.logpersistd* for a non-persistent collection
that does not survive a reboot, and to use persist.logd.logpersistd*
for persistent collection that does survive a reboot.

Added logd.logpersistd.enable to gate when logpersist service can be
run allowing the properties to be adjusted safely prior to this state
as is the case for device property.

NB: /init will complain when trying to trampoline an empty property,
    this is acceptable for functionality, but may be considered
    annoying from the logging perspective.

Bug: 28936216
Bug: 29831823
Change-Id: I97317e8eedfae4daa8e3ef39e64e7c5c23d8b573
2016-07-08 11:06:06 -07:00
Mark Salyzyn
e735a7305b logcat: help spelling correction
threadtime and added clarity for adverbs

Bug: 29916087
Change-Id: Idbed8bc74147c105eaced940d035d0649a244b18
2016-07-06 13:33:57 -07:00
Mark Salyzyn
9cfd1c6ebc logcat: format verbs and adverbs
Bug: 29916087
Change-Id: I039c95b9dc0aa88f1219121513899934381453ae
2016-07-06 11:16:07 -07:00
Ruchi Kandoi
c1b26acae2 logd: logcat -L takes longer causing vold to timeout.
Temporary fix to prevent device from getting stuck at boot.

Bug: 28788401
Change-Id: Ie4246fc3c9eb7a3af2cb909546811c85997515da
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
2016-06-14 15:26:30 -07:00
Mark Salyzyn
cd5118bf1e logcatd: add stop and clear actions
- add stop and clear (and stop) actions to logcatd.rc
- use stop and clear actions in logpersist script

Bug: 28936216
Change-Id: Id05118fb51e40609fd7b3a934cf9302f67ef6d1d
2016-06-10 21:43:16 +00:00
Mark Salyzyn
8d2a65572b logcatd: Do not su for setprop
sepolicy now permits setting persist.logd.logpersistd in shell

Bug: 28936216
2016-06-10 21:42:47 +00:00
Mark Salyzyn
b7d059bb2f logcat: clear when specifying file output
If -c and -f are both specified, clear the files rather
than notifying the logger to clear its data. The -f then
acts like a switch between clearing the in-memory log
data, or the on-disk logrotate data.

Bug: 28936216
Change-Id: Ib1d1fb46ea09f81a2fd9bebb6c8f0f9f2355f6e8
2016-06-10 18:10:01 +00:00
Mark Salyzyn
1325ebfab2 Revert "logcat: expand -n, -r and -b"
This reverts commit 33c262513f.

Bug: 28120456
Bug: 22654233
Change-Id: I2a13f009d9e08dc2389b9872e45e95e0563af22f
2016-06-08 08:22:19 -07:00
Mark Salyzyn
1d945119c0 logpersist: switch to pgrep from ps
Changes expected output from a line cut from the less than portable
ps output to reporting the pid of logcatd (uid=logd comm=logcat).
Preserve reporting an error code if logcatd did not start.

Bug: 29075536
Change-Id: I61aa0a4787d4594c415d2c7db5bbb0e512676bf8
2016-06-02 09:51:13 -07:00
Mark Salyzyn
e7e5f1b6ae logcat: confirm -g result after -c
Bug: 28451229
Change-Id: I43a1721ae991cc1316335ba4b3b868b904926d42
2016-04-29 11:33:26 -07:00
Chih-Hung Hsieh
1cc82ce95c Fix google-explicit-constructor warnings.
Bug: 28341362
Change-Id: I2cf746fd07addc6e6c22e98e2a5bb8a8ce47c885
2016-04-25 13:49:46 -07:00
Mark Salyzyn
2e210e4650 logpersist: incorporate size and buffer tunables
- Add hidden -n and -b flags that propagate to the underlying
  logcat command. Publish aliases in help as --size and --buffer.
- Add --clear for start command so it clears before starting
- shell script bloating up to deal with option validation and
  provide ERROR: and WARNING: advice.

ToDo:

- Deprecate shell script and replace with Eng and Userdebug
  only Developer Options, before it becomes too powerful
  or bloated to force us to rewrite an expendable like this
  into C++.

Bug: 28120456
Change-Id: I0dff8acaa1e5c929454760cfa2801924956bc25d
2016-04-18 08:54:39 -07:00
Mark Salyzyn
3c535de75e logcat: apct test failures
(cherry pick from 3842b1a5f6)

Change-Id: I100a5071c059fe9fa85bbdc33db552b16d7bdf60
2016-04-15 16:38:42 +00:00
Mark Salyzyn
33c262513f logcat: expand -n, -r and -b
- Add property expansion to the -n/--rotate-count,
  -r/--rotate-kbytes and -b/--buffer parameters.
  e.g. -r '${logcat.rotate-count:-6}' will expand the property
  logcat.rotate-count, and if not present will default to 6
- Add gtest to confirm mid-stream expansion
- No longer support ",:;<whitespace>" for buffer tokenization,
  settling on only supporting ",".

Bug: 28120456
Change-Id: I7ebb6146f72047631536c457952fa50d0abb98ab
2016-04-13 11:43:03 -07:00
Mark Salyzyn
4517773296 logcat: allow comma-separate list of buffers
- Add parsing to support comma+ separated list of buffers.
- Move get_size test into a standalone get_groups function
- add some additional tests for this feature, leveraging
  get_groups to confirm buffer selection.

Bug: 28120456
Change-Id: I0b42736c08cf4b2a435cb74cda540dc163a26bd1
2016-04-13 11:42:57 -07:00
Mark Salyzyn
378f4745a2 logcat: Adjust help to make it more meaningful
It is not clear about the long option aliases, list
them comma separate first for clarity. Squash lines
of help content if possible. Lock to 3 indents, one
for options, another for text on same line as options
and another for next line or continuation.

Bug: 28120456
Change-Id: I5331acde3ac0fd3b87f6699ba108f6cef46a1563
2016-04-13 11:42:52 -07:00
Mark Salyzyn
3842b1a5f6 logcat: apct test failures
Bug: 27241615
Change-Id: I100a5071c059fe9fa85bbdc33db552b16d7bdf60
2016-04-12 22:36:04 +00:00
Mark Salyzyn
1ab87e7712 logcat: -f <non-existent-directory>/<filename> segfaults
(cherry pick from commit c18c2130d0)

- Check if the result of opendir is NULL in lastLogTime
- Cleanup: alphabetically sorted long options, reserved
  an alias for --regex
- Add a unit test, non existent directory should return
  gracefully with an exit(1) and not SIGSEGV.

NB: This failure was with eng/debug feature logpersist
    turned on, /data/misc/logd/ directory was missing,
    deleted, or temporarily inaccessible.

Bug: 27954627
Change-Id: I60246a53b02fdd7e5490fe458b02ad7b14843584
2016-04-01 12:54:10 -07:00
Mark Salyzyn
c18c2130d0 logcat: -f <non-existent-directory>/<filename> segfaults
- Check if the result of opendir is NULL in lastLogTime
- Cleanup: alphabetically sorted long options, reserved
  an alias for --regex
- Add a unit test, non existent directory should return
  gracefully with an exit(1) and not SIGSEGV.

NB: This failure was with eng/debug feature logpersist
    turned on, /data/misc/logd/ directory was missing,
    deleted, or temporarily inaccessible.

Bug: 27954627
Change-Id: I60246a53b02fdd7e5490fe458b02ad7b14843584
2016-04-01 09:42:32 -07:00
Mark Salyzyn
3bef8973aa logcat: add --print flag
(cherry pick from commit c9202777cf)

To be used in combination with --regex and --max-count flags
to allow all prints to pass through, but still stop when
max-count is hit.

Bug: 27706081
Change-Id: Idaa9f0b44586a885b9d9f367824b0072c0853227
2016-03-30 16:31:35 -07:00
Mark Salyzyn
7ec59405ce logcat: posixize and extend long arguments
(cherry pick from commit d85f6461b6)

- change _ to - for long arguments
- added --tail as hidden undocumented alias for -t
- added --head as hidden undocumented alias for --max-count

Bug: 27706081
Change-Id: I614cc83ae56b305b267f64ed05dc3ed3027dabd4
2016-03-30 16:29:56 -07:00
Mark Salyzyn
df42ce4cf3 logcat: support --regex on binary buffers as-is
(cherry pick from commit aa730c1145)

- Do not restrict regex on LOG_ID_EVENTS or LOG_ID_SECURITY.
- some logcat_panic messages need to incorporate a newline.
- deal with some coding standards issues.

Bug: 27706081
Change-Id: Ie647fd62d027b01004177559d68b8e5a346705e6
2016-03-30 16:28:34 -07:00
Mark Salyzyn
9cc9cf0280 logcat: do not assign 0 or NULL to global variables
(cherry pick from commit c6d6652df5)

Bug: 27706081
Change-Id: If29d8d688ca7cce9b22227eeff1e9b500e728a50
2016-03-30 16:27:18 -07:00
Casey Dahlin
1164ef6a73 logcat: Add --max-count option
(cherry pick from commit 6ac498d4bb)

This new option causes logcat to quit after it prints N messages.

Test: New unit test passes
Bug: 27706081
Change-Id: Ie52ddf300160a041e68a6bac0ae7ade68bb28a7c
2016-03-30 16:25:40 -07:00
Casey Dahlin
0f7732d708 logcat: Add --regex option
(cherry pick from commit dc42a8734e)

You can now filter log output by a regex on the messages.

Test: New unit test passes
Bug: 27706081
Change-Id: Idfa637f62a25fb1b92e9b49b89572dff0fec6e08
2016-03-30 16:24:26 -07:00
Mark Salyzyn
c9202777cf logcat: add --print flag
To be used in combination with --regex and --max-count flags
to allow all prints to pass through, but still stop when
max-count is hit.

Bug: 27706081
Change-Id: Idaa9f0b44586a885b9d9f367824b0072c0853227
2016-03-30 16:11:37 -07:00
Mark Salyzyn
d85f6461b6 logcat: posixize and extend long arguments
- change _ to - for long arguments
- added --tail as hidden undocumented alias for -t
- added --head as hidden undocumented alias for --max-count

Bug: 27706081
Change-Id: I614cc83ae56b305b267f64ed05dc3ed3027dabd4
2016-03-30 16:11:37 -07:00
Mark Salyzyn
aa730c1145 logcat: support --regex on binary buffers as-is
- Do not restrict regex on LOG_ID_EVENTS or LOG_ID_SECURITY.
- some logcat_panic messages need to incorporate a newline.
- deal with some coding standards issues.

Bug: 27706081
Change-Id: Ie647fd62d027b01004177559d68b8e5a346705e6
2016-03-30 16:11:37 -07:00
Mark Salyzyn
c6d6652df5 logcat: do not assign 0 or NULL to global variables
Bug: 27706081
Change-Id: If29d8d688ca7cce9b22227eeff1e9b500e728a50
2016-03-30 16:11:37 -07:00
Casey Dahlin
6ac498d4bb logcat: Add --max-count option
This new option causes logcat to quit after it prints N messages.

Test: New unit test passes
Bug: 27706081
Change-Id: Ie52ddf300160a041e68a6bac0ae7ade68bb28a7c
2016-03-25 13:55:29 -07:00