diff options
author | Mark Salyzyn | 2014-02-11 14:29:31 -0600 |
---|---|---|
committer | Mark Salyzyn | 2014-03-13 16:48:07 -0500 |
commit | dfa7a07f5be656cfafdb4e75916bc9dcd9e592e7 (patch) | |
tree | a8e488d706cad455822767ee92ba198acb58f3b7 /liblog | |
parent | 64d6fe936253b336049c285369a56cf139bd002f (diff) | |
download | platform-system-core-dfa7a07f5be656cfafdb4e75916bc9dcd9e592e7.tar.gz platform-system-core-dfa7a07f5be656cfafdb4e75916bc9dcd9e592e7.tar.xz platform-system-core-dfa7a07f5be656cfafdb4e75916bc9dcd9e592e7.zip |
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 18a5432158ad43b8faefe4950b30e760200ce0b4)
Change-Id: I1572338c1b34bd968ad7867857ef708156ec3b6a
Diffstat (limited to 'liblog')
-rw-r--r-- | liblog/Android.mk | 6 | ||||
-rw-r--r-- | liblog/log_read.c | 61 | ||||
-rw-r--r-- | liblog/log_read_kern.c | 35 |
3 files changed, 91 insertions, 11 deletions
diff --git a/liblog/Android.mk b/liblog/Android.mk index c18dc48c1..4fe20db2f 100644 --- a/liblog/Android.mk +++ b/liblog/Android.mk | |||
@@ -22,6 +22,10 @@ else | |||
22 | liblog_sources := logd_write_kern.c | 22 | liblog_sources := logd_write_kern.c |
23 | endif | 23 | endif |
24 | 24 | ||
25 | ifneq ($(filter userdebug eng,$(TARGET_BUILD_VARIANT)),) | ||
26 | liblog_cflags := -DUSERDEBUG_BUILD=1 | ||
27 | endif | ||
28 | |||
25 | # some files must not be compiled when building against Mingw | 29 | # some files must not be compiled when building against Mingw |
26 | # they correspond to features not used by our host development tools | 30 | # they correspond to features not used by our host development tools |
27 | # which are also hard or even impossible to port to native Win32 | 31 | # which are also hard or even impossible to port to native Win32 |
@@ -80,11 +84,13 @@ include $(BUILD_HOST_STATIC_LIBRARY) | |||
80 | include $(CLEAR_VARS) | 84 | include $(CLEAR_VARS) |
81 | LOCAL_MODULE := liblog | 85 | LOCAL_MODULE := liblog |
82 | LOCAL_SRC_FILES := $(liblog_target_sources) | 86 | LOCAL_SRC_FILES := $(liblog_target_sources) |
87 | LOCAL_CFLAGS := $(liblog_cflags) | ||
83 | include $(BUILD_STATIC_LIBRARY) | 88 | include $(BUILD_STATIC_LIBRARY) |
84 | 89 | ||
85 | include $(CLEAR_VARS) | 90 | include $(CLEAR_VARS) |
86 | LOCAL_MODULE := liblog | 91 | LOCAL_MODULE := liblog |
87 | LOCAL_WHOLE_STATIC_LIBRARIES := liblog | 92 | LOCAL_WHOLE_STATIC_LIBRARIES := liblog |
93 | LOCAL_CFLAGS := $(liblog_cflags) | ||
88 | include $(BUILD_SHARED_LIBRARY) | 94 | include $(BUILD_SHARED_LIBRARY) |
89 | 95 | ||
90 | include $(call first-makefiles-under,$(LOCAL_PATH)) | 96 | include $(call first-makefiles-under,$(LOCAL_PATH)) |
diff --git a/liblog/log_read.c b/liblog/log_read.c index 6f6fe5f2c..e4acac2af 100644 --- a/liblog/log_read.c +++ b/liblog/log_read.c | |||
@@ -296,11 +296,8 @@ done: | |||
296 | return ret; | 296 | return ret; |
297 | } | 297 | } |
298 | 298 | ||
299 | int android_logger_clear(struct logger *logger) | 299 | static int check_log_success(char *buf, ssize_t ret) |
300 | { | 300 | { |
301 | char buf[512]; | ||
302 | |||
303 | ssize_t ret = send_log_msg(logger, "clear %d", buf, sizeof(buf)); | ||
304 | if (ret < 0) { | 301 | if (ret < 0) { |
305 | return ret; | 302 | return ret; |
306 | } | 303 | } |
@@ -312,8 +309,16 @@ int android_logger_clear(struct logger *logger) | |||
312 | return 0; | 309 | return 0; |
313 | } | 310 | } |
314 | 311 | ||
312 | int android_logger_clear(struct logger *logger) | ||
313 | { | ||
314 | char buf[512]; | ||
315 | |||
316 | return check_log_success(buf, | ||
317 | send_log_msg(logger, "clear %d", buf, sizeof(buf))); | ||
318 | } | ||
319 | |||
315 | /* returns the total size of the log's ring buffer */ | 320 | /* returns the total size of the log's ring buffer */ |
316 | int android_logger_get_log_size(struct logger *logger) | 321 | long android_logger_get_log_size(struct logger *logger) |
317 | { | 322 | { |
318 | char buf[512]; | 323 | char buf[512]; |
319 | 324 | ||
@@ -326,14 +331,28 @@ int android_logger_get_log_size(struct logger *logger) | |||
326 | return -1; | 331 | return -1; |
327 | } | 332 | } |
328 | 333 | ||
329 | return atoi(buf); | 334 | return atol(buf); |
330 | } | 335 | } |
331 | 336 | ||
337 | #ifdef USERDEBUG_BUILD | ||
338 | |||
339 | int android_logger_set_log_size(struct logger *logger, unsigned long size) | ||
340 | { | ||
341 | char buf[512]; | ||
342 | |||
343 | snprintf(buf, sizeof(buf), "setLogSize %d %lu", | ||
344 | logger ? logger->id : (unsigned) -1, size); | ||
345 | |||
346 | return check_log_success(buf, send_log_msg(NULL, NULL, buf, sizeof(buf))); | ||
347 | } | ||
348 | |||
349 | #endif /* USERDEBUG_BUILD */ | ||
350 | |||
332 | /* | 351 | /* |
333 | * returns the readable size of the log's ring buffer (that is, amount of the | 352 | * returns the readable size of the log's ring buffer (that is, amount of the |
334 | * log consumed) | 353 | * log consumed) |
335 | */ | 354 | */ |
336 | int android_logger_get_log_readable_size(struct logger *logger) | 355 | long android_logger_get_log_readable_size(struct logger *logger) |
337 | { | 356 | { |
338 | char buf[512]; | 357 | char buf[512]; |
339 | 358 | ||
@@ -346,7 +365,7 @@ int android_logger_get_log_readable_size(struct logger *logger) | |||
346 | return -1; | 365 | return -1; |
347 | } | 366 | } |
348 | 367 | ||
349 | return atoi(buf); | 368 | return atol(buf); |
350 | } | 369 | } |
351 | 370 | ||
352 | /* | 371 | /* |
@@ -383,6 +402,32 @@ ssize_t android_logger_get_statistics(struct logger_list *logger_list, | |||
383 | return send_log_msg(NULL, NULL, buf, len); | 402 | return send_log_msg(NULL, NULL, buf, len); |
384 | } | 403 | } |
385 | 404 | ||
405 | #ifdef USERDEBUG_BUILD | ||
406 | |||
407 | ssize_t android_logger_get_prune_list(struct logger_list *logger_list UNUSED, | ||
408 | char *buf, size_t len) | ||
409 | { | ||
410 | return send_log_msg(NULL, "getPruneList", buf, len); | ||
411 | } | ||
412 | |||
413 | int android_logger_set_prune_list(struct logger_list *logger_list UNUSED, | ||
414 | char *buf, size_t len) | ||
415 | { | ||
416 | const char cmd[] = "setPruneList "; | ||
417 | const size_t cmdlen = sizeof(cmd) - 1; | ||
418 | |||
419 | if (strlen(buf) > (len - cmdlen)) { | ||
420 | return -ENOMEM; /* KISS */ | ||
421 | } | ||
422 | memmove(buf + cmdlen, buf, len - cmdlen); | ||
423 | buf[len - 1] = '\0'; | ||
424 | memcpy(buf, cmd, cmdlen); | ||
425 | |||
426 | return check_log_success(buf, send_log_msg(NULL, NULL, buf, len)); | ||
427 | } | ||
428 | |||
429 | #endif /* USERDEBUG_BUILD */ | ||
430 | |||
386 | struct logger_list *android_logger_list_alloc(int mode, | 431 | struct logger_list *android_logger_list_alloc(int mode, |
387 | unsigned int tail, | 432 | unsigned int tail, |
388 | pid_t pid) | 433 | pid_t pid) |
diff --git a/liblog/log_read_kern.c b/liblog/log_read_kern.c index 59a7a0b19..483b6b6d8 100644 --- a/liblog/log_read_kern.c +++ b/liblog/log_read_kern.c | |||
@@ -227,16 +227,26 @@ int android_logger_clear(struct logger *logger) | |||
227 | } | 227 | } |
228 | 228 | ||
229 | /* returns the total size of the log's ring buffer */ | 229 | /* returns the total size of the log's ring buffer */ |
230 | int android_logger_get_log_size(struct logger *logger) | 230 | long android_logger_get_log_size(struct logger *logger) |
231 | { | 231 | { |
232 | return logger_ioctl(logger, LOGGER_GET_LOG_BUF_SIZE, O_RDWR); | 232 | return logger_ioctl(logger, LOGGER_GET_LOG_BUF_SIZE, O_RDWR); |
233 | } | 233 | } |
234 | 234 | ||
235 | #ifdef USERDEBUG_BUILD | ||
236 | |||
237 | int android_logger_set_log_size(struct logger *logger UNUSED, | ||
238 | unsigned long size UNUSED) | ||
239 | { | ||
240 | return -ENOTSUP; | ||
241 | } | ||
242 | |||
243 | #endif /* USERDEBUG_BUILD */ | ||
244 | |||
235 | /* | 245 | /* |
236 | * returns the readable size of the log's ring buffer (that is, amount of the | 246 | * returns the readable size of the log's ring buffer (that is, amount of the |
237 | * log consumed) | 247 | * log consumed) |
238 | */ | 248 | */ |
239 | int android_logger_get_log_readable_size(struct logger *logger) | 249 | long android_logger_get_log_readable_size(struct logger *logger) |
240 | { | 250 | { |
241 | return logger_ioctl(logger, LOGGER_GET_LOG_LEN, O_RDONLY); | 251 | return logger_ioctl(logger, LOGGER_GET_LOG_LEN, O_RDONLY); |
242 | } | 252 | } |
@@ -253,15 +263,34 @@ int android_logger_get_log_version(struct logger *logger) | |||
253 | /* | 263 | /* |
254 | * returns statistics | 264 | * returns statistics |
255 | */ | 265 | */ |
266 | static const char unsupported[] = "18\nNot Supported\n\f"; | ||
256 | 267 | ||
257 | ssize_t android_logger_get_statistics(struct logger_list *logger_list UNUSED, | 268 | ssize_t android_logger_get_statistics(struct logger_list *logger_list UNUSED, |
258 | char *buf, size_t len) | 269 | char *buf, size_t len) |
259 | { | 270 | { |
260 | static const char unsupported[] = "18\nNot Supported\n\f"; | ||
261 | strncpy(buf, unsupported, len); | 271 | strncpy(buf, unsupported, len); |
262 | return -ENOTSUP; | 272 | return -ENOTSUP; |
263 | } | 273 | } |
264 | 274 | ||
275 | #ifdef USERDEBUG_BUILD | ||
276 | |||
277 | ssize_t android_logger_get_prune_list(struct logger_list *logger_list UNUSED, | ||
278 | char *buf, size_t len) | ||
279 | { | ||
280 | strncpy(buf, unsupported, len); | ||
281 | return -ENOTSUP; | ||
282 | } | ||
283 | |||
284 | int android_logger_set_prune_list(struct logger_list *logger_list UNUSED, | ||
285 | char *buf, size_t len) | ||
286 | { | ||
287 | static const char unsupported_error[] = "Unsupported"; | ||
288 | strncpy(buf, unsupported, len); | ||
289 | return -ENOTSUP; | ||
290 | } | ||
291 | |||
292 | #endif /* USERDEBUG_BUILD */ | ||
293 | |||
265 | struct logger_list *android_logger_list_alloc(int mode, | 294 | struct logger_list *android_logger_list_alloc(int mode, |
266 | unsigned int tail, | 295 | unsigned int tail, |
267 | pid_t pid) | 296 | pid_t pid) |