Commit graph

22 commits

Author SHA1 Message Date
Mark Salyzyn
a073c39616 logcatd: introduce logcatd executable
logcatd is the same as logcat, except that the -L flag, if supplied,
runs once, then the command re-runs itself without the -L flag with
the same argument set.  By introducing a logcatd daemon executable
we can solve the problem of the longish reads from pstore that
sometimes occur when the system is excessively busy, starving this
background cgroup daemon as we absorb the delay in a backgrounded
init "service", rather than in a forgrounded init "exec".  This would
not have been efficiently possible without the introduction of
liblogcat.

There are no doubt many flags that make no sense to run twice with,
and without, the -L flag.  In the general sense we expect the caller
to perform the correct set of operations and not pick these nonsense
operations.  logcatd is only supplied on engineering and debug builds
for logpersist, and is only an automated aid to triage.

Test: gTest logcat-unit-tests
Test: manual confirm logpersist functions as expected, required reboot
Bug: 28788401
Bug: 30041146
Bug: 30612424
Bug: 35326290
Change-Id: I53ba31970749daf37eef42636f039f485932416f
2017-04-04 08:01:50 -07:00
Mark Salyzyn
e9ade17418 liblogcat: introduce getopt_long_r
Resolve one of the threading issues by creating a private C++ified
copy of getopt_long_r that started out its life as the bionic
getopt_long, but is reentrant.  Adds a new state context for the
stderr stream called optstderr.  Utilize this new function in logcat.
Control opterr and optstderr to match liblogcat expectations.  Correct
and fortify const.

Alternative would be to lock around _all_ getopt callers.  This has
the advantage of requiring _no_ locks that could get in the way of
using liblogcat in a signal handler.  The log reader interface does
run the risk of incurring locks and heap allocations though, so there
is more work to be done for that final goal.

Test: gTest logcat-unit-tests
Bug: 35326290
Change-Id: Ibb1b374c55d357d5d7fa5ad00bfaf07ae0bc4ba5
2017-03-06 08:40:16 -08:00
Mark Salyzyn
eb40816fb8 liblogcat: LOCAL_C_INCLUDE_DIRS correction
Test: compile
Bug: 35326290
Change-Id: I62b46443a6b9149577e85d4f512c3946b467a1fb
2017-02-21 08:48:29 -08:00
Mark Salyzyn
6dabc81a0b liblogcat: add android_logcat_popen and android_logcat_system
Supply a wrapper to the logcat API that provides some analogous
functionality to popen and system libc calls with some bits of
KISS shell-like parsing for environment, quotes and error
redirection handling.

Test: gTest logcat-unit-tests
Bug: 35326290
Change-Id: I9494ce71267ad2b2bec7fcccfc7d4beddae9aea6
2017-02-17 14:42:14 -08:00
Mark Salyzyn
c0cf90d1fb logcat: Create liblogcat
Try to leverage as much of logcat as-is and produce a viable
library API that others can use for their own logcat execution.

Added a test to check ANDROID_PRINTF_LOG environment variable.

Test: gTest logcat-unit-tests
Bug: 35326290
Change-Id: I30de692ea9d83e6fd6e5d9e7cf93d31401a88a40
2017-02-17 14:42:14 -08: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
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
8c943b6dc8 logpersist: bundle with logcatd service
Bug: 23186545
Change-Id: I130d7c7e120acb372e58aec028f39e161d53628e
2015-09-21 13:53:01 -07:00
Tom Cherry
20391b1de5 bundle init.rc contents with its service
Bug: 23186545
Change-Id: I52616b8ab1165fdef716f9b8f958665f2308c12e
2015-08-21 10:14:43 -07:00
Mark Salyzyn
3ef730c57f logcat: -f run in background
- if saving to file, set SP_BACKGROUND policy
- if saving to file, set BATCH priority
- sort include files

Bug: 19608716
Change-Id: I00acb8b8db0d2ff9ff36c97f9e74604d31938376
2015-06-02 14:56:44 -07:00
Mark Salyzyn
f3555d9427 logcat: -f flag to continue
On startup, check the current logging content, then grab logs from
that time forward rather than restarting from the beginning. Add
support for reading tail time down to the nano-second.

Bonus, permits us to create a logcatd logpersist daemon

Bug: 19608716
Change-Id: Iaab58de4c02b7f97c69de12cf954fedc2163059e
2015-06-02 14:56:44 -07:00
Mark Salyzyn
b149e245c8 logcat: turn on -Werror
- Deal with some -Wunused issues

Change-Id: Ic4ab9a49f13e156a73d40266e413dee3e6396178
2014-05-02 14:15:59 -07:00
Mark Salyzyn
1c95047939 logd: liblog: logcat: enable prune features for user
- Enable whitelist, blacklist and logsize tuneables for user

Change-Id: Id0c283844c71c5263a8cfbebf2e550f7ac415858
2014-04-02 13:12:04 -07:00
Mark Salyzyn
dfa7a07f5b logd: liblog: logcat: Add LogWhiteBlackList
- liblog android_logger_get_log_size and android_logger_get_readable_size
  adjusted to return long instead of int because of -G flag extending range

NB: ifdef'd only for userdebug and eng builds

- liblog Add android_logger_[sg]et_prune_list and android_logger_set_log_size
- logcat Add -P, -p and -G flags
- logd Add LogWhiteBlackList and configurable log size

(cherry picked from commit 18a5432158)

Change-Id: I1572338c1b34bd968ad7867857ef708156ec3b6a
2014-03-13 14:48:07 -07:00
Mark Salyzyn
65772ca7d7 logcat: Add logcat test suite
(cherry picked from commit 2807db9a26)

Change-Id: Ic4c84b88b8d899965c9765bdc3ee223ef73ba7d1
2014-01-27 15:18:49 -08:00
Doug Zongker
da077ee77a construct event-log-tags via the new build mechanism
The build system now unions together all *.logtags files found in
LOCAL_SRC_FILES to construct /system/etc/event-log-tags.
2009-12-03 10:35:41 -08:00
Doug Zongker
0e5e7ef1fe strip comments from event-log-tags on device
This saves about 8k from the system image.

Bug: 2036961
2009-08-06 16:43:47 -07:00
The Android Open Source Project
e4749f30e5 auto import from //branches/cupcake/...@137197 2009-03-09 11:52:15 -07:00
The Android Open Source Project
dd7bc3319d auto import from //depot/cupcake/@135843 2009-03-03 19:32:55 -08:00
The Android Open Source Project
e54eebbf1a auto import from //depot/cupcake/@135843 2009-03-03 18:29:04 -08:00
The Android Open Source Project
4f6e8d7a00 Initial Contribution 2008-10-21 07:00:00 -07:00