Merge "logcat: Add -D print dividers flag"
This commit is contained in:
commit
da26197873
1 changed files with 22 additions and 10 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2006-2014 The Android Open Source Project
|
// Copyright 2006-2015 The Android Open Source Project
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
@ -178,18 +178,19 @@ error:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void maybePrintStart(log_device_t* dev) {
|
static void maybePrintStart(log_device_t* dev, bool printDividers) {
|
||||||
if (!dev->printed) {
|
if (!dev->printed || printDividers) {
|
||||||
dev->printed = true;
|
|
||||||
if (g_devCount > 1 && !g_printBinary) {
|
if (g_devCount > 1 && !g_printBinary) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
snprintf(buf, sizeof(buf), "--------- beginning of %s\n",
|
snprintf(buf, sizeof(buf), "--------- %s %s\n",
|
||||||
|
dev->printed ? "switch to" : "beginning of",
|
||||||
dev->device);
|
dev->device);
|
||||||
if (write(g_outFD, buf, strlen(buf)) < 0) {
|
if (write(g_outFD, buf, strlen(buf)) < 0) {
|
||||||
perror("output error");
|
perror("output error");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dev->printed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,6 +228,7 @@ static void show_help(const char *cmd)
|
||||||
" -n <count> Sets max number of rotated logs to <count>, default 4\n"
|
" -n <count> Sets max number of rotated logs to <count>, default 4\n"
|
||||||
" -v <format> Sets the log print format, where <format> is:\n\n"
|
" -v <format> Sets the log print format, where <format> is:\n\n"
|
||||||
" brief color long process raw tag thread threadtime time\n\n"
|
" brief color long process raw tag thread threadtime time\n\n"
|
||||||
|
" -D print dividers between each log buffer\n"
|
||||||
" -c clear (flush) the entire log and exit\n"
|
" -c clear (flush) the entire log and exit\n"
|
||||||
" -d dump the log and then exit (don't block)\n"
|
" -d dump the log and then exit (don't block)\n"
|
||||||
" -t <count> print only the most recent <count> lines (implies -d)\n"
|
" -t <count> print only the most recent <count> lines (implies -d)\n"
|
||||||
|
|
@ -329,6 +331,7 @@ int main(int argc, char **argv)
|
||||||
log_device_t* devices = NULL;
|
log_device_t* devices = NULL;
|
||||||
log_device_t* dev;
|
log_device_t* dev;
|
||||||
bool needBinary = false;
|
bool needBinary = false;
|
||||||
|
bool printDividers = false;
|
||||||
struct logger_list *logger_list;
|
struct logger_list *logger_list;
|
||||||
unsigned int tail_lines = 0;
|
unsigned int tail_lines = 0;
|
||||||
log_time tail_time(log_time::EPOCH);
|
log_time tail_time(log_time::EPOCH);
|
||||||
|
|
@ -345,7 +348,7 @@ int main(int argc, char **argv)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = getopt(argc, argv, "cdt:T:gG:sQf:r:n:v:b:BSpP:");
|
ret = getopt(argc, argv, "cdDt:T:gG:sQf:r:n:v:b:BSpP:");
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -398,6 +401,10 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'D':
|
||||||
|
printDividers = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'g':
|
case 'g':
|
||||||
getLogSize = 1;
|
getLogSize = 1;
|
||||||
break;
|
break;
|
||||||
|
|
@ -839,8 +846,10 @@ int main(int argc, char **argv)
|
||||||
if (needBinary)
|
if (needBinary)
|
||||||
android::g_eventTagMap = android_openEventTagMap(EVENT_TAG_MAP_FILE);
|
android::g_eventTagMap = android_openEventTagMap(EVENT_TAG_MAP_FILE);
|
||||||
|
|
||||||
|
dev = NULL;
|
||||||
while (1) {
|
while (1) {
|
||||||
struct log_msg log_msg;
|
struct log_msg log_msg;
|
||||||
|
log_device_t* d;
|
||||||
int ret = android_logger_list_read(logger_list, &log_msg);
|
int ret = android_logger_list_read(logger_list, &log_msg);
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
|
@ -865,17 +874,20 @@ int main(int argc, char **argv)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(dev = devices; dev; dev = dev->next) {
|
for(d = devices; d; d = d->next) {
|
||||||
if (android_name_to_log_id(dev->device) == log_msg.id()) {
|
if (android_name_to_log_id(d->device) == log_msg.id()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!dev) {
|
if (!d) {
|
||||||
fprintf(stderr, "read: Unexpected log ID!\n");
|
fprintf(stderr, "read: Unexpected log ID!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
android::maybePrintStart(dev);
|
if (dev != d) {
|
||||||
|
dev = d;
|
||||||
|
android::maybePrintStart(dev, printDividers);
|
||||||
|
}
|
||||||
if (android::g_printBinary) {
|
if (android::g_printBinary) {
|
||||||
android::printBinary(&log_msg);
|
android::printBinary(&log_msg);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue