diff options
author | Mark Salyzyn <salyzyn@google.com> | 2014-05-06 07:34:59 -0700 |
---|---|---|
committer | Mark Salyzyn <salyzyn@google.com> | 2014-05-06 14:58:41 -0700 |
commit | 671e343c7d9c832eca093325c0b8b934c47a83b4 (patch) | |
tree | 66ade0a7ab0602e6455f32ba533ba9a76e2e12a0 /logcat | |
parent | 5c02b2760e11e8b77452c345c788e4cda289f788 (diff) | |
download | core-671e343c7d9c832eca093325c0b8b934c47a83b4.tar.gz core-671e343c7d9c832eca093325c0b8b934c47a83b4.tar.bz2 core-671e343c7d9c832eca093325c0b8b934c47a83b4.zip |
logd: logcat: Add persist.logd.size group of properties
- logd Add persist.logd.size (global), persist.logd.size.<logid>
- logcat report a more flexible multiplier in -g command.
Bug: 14563261
Bug: 14469172
Change-Id: Ie389caa14ad3ae3d4a3a3cc463425bb9dbc5e483
Diffstat (limited to 'logcat')
-rw-r--r-- | logcat/logcat.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp index ea4634586..db4fddd5f 100644 --- a/logcat/logcat.cpp +++ b/logcat/logcat.cpp @@ -281,6 +281,30 @@ static int setLogFormat(const char * formatString) return 0; } +static const char multipliers[][2] = { + { "" }, + { "K" }, + { "M" }, + { "G" } +}; + +static unsigned long value_of_size(unsigned long value) +{ + for (unsigned i = 0; + (i < sizeof(multipliers)/sizeof(multipliers[0])) && (value >= 1024); + value /= 1024, ++i) ; + return value; +} + +static const char *multiplier_of_size(unsigned long value) +{ + unsigned i; + for (i = 0; + (i < sizeof(multipliers)/sizeof(multipliers[0])) && (value >= 1024); + value /= 1024, ++i) ; + return multipliers[i]; +} + int main(int argc, char **argv) { int err; @@ -715,9 +739,10 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } - printf("%s: ring buffer is %ldKb (%ldKb consumed), " + printf("%s: ring buffer is %ld%sb (%ld%sb consumed), " "max entry is %db, max payload is %db\n", dev->device, - size / 1024, readable / 1024, + value_of_size(size), multiplier_of_size(size), + value_of_size(readable), multiplier_of_size(readable), (int) LOGGER_ENTRY_MAX_LEN, (int) LOGGER_ENTRY_MAX_PAYLOAD); } |