From 671e343c7d9c832eca093325c0b8b934c47a83b4 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Tue, 6 May 2014 07:34:59 -0700 Subject: logd: logcat: Add persist.logd.size group of properties - logd Add persist.logd.size (global), persist.logd.size. - logcat report a more flexible multiplier in -g command. Bug: 14563261 Bug: 14469172 Change-Id: Ie389caa14ad3ae3d4a3a3cc463425bb9dbc5e483 --- logcat/logcat.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'logcat/logcat.cpp') diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp index ea46345..db4fddd 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); } -- cgit v1.1