Commit graph

184 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
Casey Dahlin
dc42a8734e logcat: Add --regex option
You can now filter log output by a regex on the messages.

Test: New unit test passes
Bug: 27706081
Change-Id: Idfa637f62a25fb1b92e9b49b89572dff0fec6e08
2016-03-25 13:55:29 -07:00
James Hawkins
588a2cad7f system/core: Cleanup direct calls to opendir by containing in a
std::unique_ptr.

Bug: 26643633
Change-Id: Ia3491fdbff086558da694ae949cf08e4c89d0307
2016-02-18 14:52:46 -08:00
Elliott Hughes
b9e53b4d2d Remove logcat's false dependency on a libutils header file.
Change-Id: Idf499d77e88d2ee7d5b1050eaf45ba29481793a4
2016-02-17 11:58:01 -08:00
Mark Salyzyn
d1f41d606b logd: use ro.debuggable instead of ro.build.type
Change-Id: Ic644f1f78e68094f700834675f4acc63386a6b92
2016-02-10 10:23:03 -08:00
Mark Salyzyn
5b89b49fc9 logcat: build cleanup
LOCAL_MODULE_TAGS debug encompasses eng

Bug: 26976972
Change-Id: I44b30f2ebb0173b203bf975f01dfead737b4e5bf
2016-02-04 13:10:19 -08:00
Mark Salyzyn
6de62e52c7 logcatd.rc: only deliver on eng and userdebug
Change-Id: I694d33a041e40fe181d3c2f1c8604765ba29e709
2016-02-04 11:11:52 -08:00
Mark Salyzyn
3bab2a9096 logpersist: missing X
Signed-off-by: LawrenceSY_Kuo@asus.com
Bug: 19608716
Change-Id: I90e0313262a02906dec71417b995fc725f78a292
2015-12-29 07:31:37 -08:00
Mark Salyzyn
8beb0d3ad7 logcat: test: rotated logs can exceed size during crash
Some crash messages can be as large as 4K, so allow
the rotated logs to have a larger size.

Change-Id: I20ef8d526ad2d5eca128d1f99f4ea2d2da426403
2015-12-18 10:35:20 -08:00
Mark Salyzyn
86052a5d4f Merge "logd: liblog: logcat: Add LOG_ID_SECURITY" 2015-12-11 17:33:33 +00:00
Mark Salyzyn
90e7af30a5 liblog: logprint add uid format modifier
Bug: 25996918
Change-Id: Idff5e080fc5c7b69e0c45d3f596eb9d632451cbd
2015-12-09 08:12:07 -08:00
Mark Salyzyn
083b037c07 logd: liblog: logcat: Add LOG_ID_SECURITY
- Largish commit, buffer and access controls done together
- Add LOG_ID_SECURITY binary content log
- Add "default" meta buffer
- allow LOG_ID_SECURITY only from AID_SYSTEM and AID_ROOT UID & GID
- Use __android_log_security() to gate logging
- Add __android_log_security_bwrite() native access to security
  logging.
- Add liblog.__security_buffer end-to-end gTest

Bug: 26029733
Change-Id: Ibcf5b4660c17c1aa6902c0d93f8ffd29c93d9a93
2015-12-08 16:46:29 -08:00
Mark Salyzyn
41ba25f864 logcat: Add --wrap timeout
Always ANDROID_LOG_WRAP_DEFAULT_TIMEOUT seconds (2 hours).
--wrap takes argument, the argument is currently ignored.

Future: Add new API that allows setting of wrap timeout.

Bug: 25929746
Bug: 21615139
Change-Id: Ib441cecfb6e4264c18adb70c705314440ba85e65
2015-12-07 14:24:02 -08:00
Mark Salyzyn
f8bff87c65 logcat: Add low hanging fruit long arguments
Add long arguments file, rotate_kbytes, rotate_count, format,
dividers, clear, buffer_size, last, buffer, binary, statistics
and prune.

Bug: 21615139
Change-Id: Ieb1bbe3d47e6711a1e91c74522630d39f8981621
2015-12-07 14:24:02 -08:00
Kristian Monsen
562e513d4b logcat: Add long arguments to logcat, support for pid filter
Bug: 21615139
Change-Id: I3e63e43067f8089c18658e4100e901fb2a9630ae
2015-12-07 14:24:02 -08:00
Mark Salyzyn
ba7a9a016b logd: liblog: logcat: switch to android_log_clockid() (2)
android_log_timestamp returns the property leading letter,
it is better to return a clockid_t with android_log_clockid()

Bug: 23668800
Change-Id: I38dee773bf3844177826b03a26b03215c79a5359
2015-12-07 18:45:31 +00:00
Mark Salyzyn
b566435b02 Merge "Revert "logd: liblog: logcat: switch to android_log_clockid()"" 2015-12-07 18:31:44 +00:00
Mark Salyzyn
9e18cdcebd Revert "logd: liblog: logcat: switch to android_log_clockid()"
This reverts commit 77b5696b1d.

Change-Id: I7711bf1a7e3f72ed29a2498d7287b725a0e624bd
2015-12-07 18:30:58 +00:00
Mark Salyzyn
9eca0e775b Merge "logd: liblog: logcat: switch to android_log_clockid()" 2015-12-07 18:16:29 +00:00
Elliott Hughes
4f71319df0 Track rename of base/ to android-base/.
Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
2015-12-04 22:00:26 -08:00
Mark Salyzyn
77b5696b1d logd: liblog: logcat: switch to android_log_clockid()
android_log_timestamp returns the property leading letter,
it is better to return a clockid_t with android_log_clockid()

Bug: 23668800
Change-Id: I3c4e3e6b87f6676950797f1f0e203b44c542ed43
2015-12-04 14:49:19 -08:00
Mark Salyzyn
b6bee33182 liblog: logd: support logd.timestamp = monotonic
if ro.logd.timestamp or persist.logd.timestamp are set to the value
monotonic then liblog writer, liblog printing and logd all switch to
recording/printing monotonic time rather than realtime. If reinit
detects a change for presist.logd.timestamp, correct the older entry
timestamps in place.

ToDo: A corner case condition where new log entries in monotonic time
      occur before logd reinit detects persist.logd.timestamp, there
      will be a few out-of-order entries, but with accurate
      timestamps. This problem does not happen for ro.logd.timestamp
      as it is set before logd starts.

NB: This offers a nano second time accuracy on all log entries
    that may be more suitable for merging with other system
    activities, such as systrace, that also use monotonic time. This
    feature is for debugging.

Bug: 23668800
Change-Id: Iee6dab7140061b1a6627254921411f61b01aa5c2
2015-11-03 15:15:51 -08:00
Mark Salyzyn
9d4203aae1 Merge changes Iefbea3b1,Ieb924b6d
am: bb51fbc4d4

* commit 'bb51fbc4d4b311ae315e4d7dd174167ebeadc2a8':
  liblog: add android_log_timestamp() private function
  liblog: logcat: add epoch and monotonic format modifiers
2015-10-29 23:05:33 +00:00
Mark Salyzyn
4cbed02e44 liblog: logcat: add epoch and monotonic format modifiers
- '-v epoch' prints seconds since Jan 1 1970
- '-v monotonic' print cpu seconds since start of device
- '-T sssss.mmm...' as alternate tail time format

NB: monotonic is a best estimate and may be out by a few ms
    given the synchronization source clue accuracy.

Bug: 23668800
Change-Id: Ieb924b6d3817669c7e53beb9c970fb626eaad460
2015-10-29 14:23:42 -07:00
Bill Yi
27bdd9a71c Merge commit '2b88845e4d7ae862d9735eec3c03d633d4f1d58d' into HEAD 2015-10-08 10:37:51 -07:00
Mark Salyzyn
603b8e50c8 logcat: do not exit buffer loop on error
- Alter logcat to collect error(s) for open, clear, get size or set
  size; moving on to other buffer ids. Then after loop completed,
  report and exit for the last error reported.

Bug: 23711431
Change-Id: I63a729d27544ea8d5c6119625c1de0210be0eb70
2015-10-07 16:23:54 -07:00