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 /logd/LogBuffer.cpp | |
parent | 5c02b2760e11e8b77452c345c788e4cda289f788 (diff) | |
download | system_core-671e343c7d9c832eca093325c0b8b934c47a83b4.zip system_core-671e343c7d9c832eca093325c0b8b934c47a83b4.tar.gz system_core-671e343c7d9c832eca093325c0b8b934c47a83b4.tar.bz2 |
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 'logd/LogBuffer.cpp')
-rw-r--r-- | logd/LogBuffer.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp index 38a237c..dc9d47e 100644 --- a/logd/LogBuffer.cpp +++ b/logd/LogBuffer.cpp @@ -14,29 +14,68 @@ * limitations under the License. */ +#include <ctype.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> +#include <cutils/properties.h> #include <log/logger.h> #include "LogBuffer.h" +#include "LogReader.h" #include "LogStatistics.h" #include "LogWhiteBlackList.h" -#include "LogReader.h" // Default #define LOG_BUFFER_SIZE (256 * 1024) // Tuned on a per-platform basis here? #define log_buffer_size(id) mMaxSize[id] +static unsigned long property_get_size(const char *key) { + char property[PROPERTY_VALUE_MAX]; + property_get(key, property, ""); + + char *cp; + unsigned long value = strtoul(property, &cp, 10); + + switch(*cp) { + case 'm': + case 'M': + value *= 1024; + /* FALLTHRU */ + case 'k': + case 'K': + value *= 1024; + /* FALLTHRU */ + case '\0': + break; + + default: + value = 0; + } + + return value; +} + LogBuffer::LogBuffer(LastLogTimes *times) : mTimes(*times) { pthread_mutex_init(&mLogElementsLock, NULL); dgram_qlen_statistics = false; + static const char global_default[] = "persist.logd.size"; + unsigned long default_size = property_get_size(global_default); + log_id_for_each(i) { - mMaxSize[i] = LOG_BUFFER_SIZE; + setSize(i, LOG_BUFFER_SIZE); + setSize(i, default_size); + + char key[PROP_NAME_MAX]; + snprintf(key, sizeof(key), "%s.%s", + global_default, android_log_id_to_name(i)); + + setSize(i, property_get_size(key)); } } |