summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2014-05-06 09:34:59 -0500
committerMark Salyzyn2014-05-06 16:58:41 -0500
commit671e343c7d9c832eca093325c0b8b934c47a83b4 (patch)
tree66ade0a7ab0602e6455f32ba533ba9a76e2e12a0 /logd/LogBuffer.cpp
parent5c02b2760e11e8b77452c345c788e4cda289f788 (diff)
downloadplatform-system-core-671e343c7d9c832eca093325c0b8b934c47a83b4.tar.gz
platform-system-core-671e343c7d9c832eca093325c0b8b934c47a83b4.tar.xz
platform-system-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 'logd/LogBuffer.cpp')
-rw-r--r--logd/LogBuffer.cpp43
1 files changed, 41 insertions, 2 deletions
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index 38a237c5d..dc9d47ee6 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -14,29 +14,68 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17#include <ctype.h>
17#include <stdio.h> 18#include <stdio.h>
19#include <stdlib.h>
18#include <string.h> 20#include <string.h>
19#include <time.h> 21#include <time.h>
20#include <unistd.h> 22#include <unistd.h>
21 23
24#include <cutils/properties.h>
22#include <log/logger.h> 25#include <log/logger.h>
23 26
24#include "LogBuffer.h" 27#include "LogBuffer.h"
28#include "LogReader.h"
25#include "LogStatistics.h" 29#include "LogStatistics.h"
26#include "LogWhiteBlackList.h" 30#include "LogWhiteBlackList.h"
27#include "LogReader.h"
28 31
29// Default 32// Default
30#define LOG_BUFFER_SIZE (256 * 1024) // Tuned on a per-platform basis here? 33#define LOG_BUFFER_SIZE (256 * 1024) // Tuned on a per-platform basis here?
31#define log_buffer_size(id) mMaxSize[id] 34#define log_buffer_size(id) mMaxSize[id]
32 35
36static unsigned long property_get_size(const char *key) {
37 char property[PROPERTY_VALUE_MAX];
38 property_get(key, property, "");
39
40 char *cp;
41 unsigned long value = strtoul(property, &cp, 10);
42
43 switch(*cp) {
44 case 'm':
45 case 'M':
46 value *= 1024;
47 /* FALLTHRU */
48 case 'k':
49 case 'K':
50 value *= 1024;
51 /* FALLTHRU */
52 case '\0':
53 break;
54
55 default:
56 value = 0;
57 }
58
59 return value;
60}
61
33LogBuffer::LogBuffer(LastLogTimes *times) 62LogBuffer::LogBuffer(LastLogTimes *times)
34 : mTimes(*times) { 63 : mTimes(*times) {
35 pthread_mutex_init(&mLogElementsLock, NULL); 64 pthread_mutex_init(&mLogElementsLock, NULL);
36 dgram_qlen_statistics = false; 65 dgram_qlen_statistics = false;
37 66
67 static const char global_default[] = "persist.logd.size";
68 unsigned long default_size = property_get_size(global_default);
69
38 log_id_for_each(i) { 70 log_id_for_each(i) {
39 mMaxSize[i] = LOG_BUFFER_SIZE; 71 setSize(i, LOG_BUFFER_SIZE);
72 setSize(i, default_size);
73
74 char key[PROP_NAME_MAX];
75 snprintf(key, sizeof(key), "%s.%s",
76 global_default, android_log_id_to_name(i));
77
78 setSize(i, property_get_size(key));
40 } 79 }
41} 80}
42 81