aboutsummaryrefslogtreecommitdiffstats
path: root/logcat
diff options
context:
space:
mode:
authorJoe Onorato <joeo@android.com>2010-03-01 09:11:54 -0800
committerJoe Onorato <joeo@android.com>2010-03-01 13:03:19 -0800
commite2bf2ea4d2846031edfc52b942ad53e5467243f6 (patch)
tree76fa7dca61684d78c93755986db60a3a6d3731e4 /logcat
parentb91bf4ba864a392412397913ee09a8c1f2e7cc87 (diff)
downloadsystem_core-e2bf2ea4d2846031edfc52b942ad53e5467243f6.tar.gz
system_core-e2bf2ea4d2846031edfc52b942ad53e5467243f6.tar.bz2
system_core-e2bf2ea4d2846031edfc52b942ad53e5467243f6.zip
Make logcat print both the main and system buffers by default. Make SLOGx macros work.
Diffstat (limited to 'logcat')
-rw-r--r--logcat/logcat.cpp55
1 files changed, 36 insertions, 19 deletions
diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp
index 43c9ccd8..670408c1 100644
--- a/logcat/logcat.cpp
+++ b/logcat/logcat.cpp
@@ -24,6 +24,7 @@
#define DEFAULT_MAX_ROTATED_LOGS 4
static AndroidLogFormat * g_logformat;
+static bool g_nonblock = false;
/* logd prefixes records with a length field */
#define RECORD_LENGTH_FIELD_SIZE_BYTES sizeof(uint32_t)
@@ -174,16 +175,6 @@ static void processBuffer(log_device_t* dev, struct logger_entry *buf)
}
}
- if (g_devCount > 1) {
- binaryMsgBuf[0] = dev->label;
- binaryMsgBuf[1] = ' ';
- bytesWritten = write(g_outFD, binaryMsgBuf, 2);
- if (bytesWritten < 0) {
- perror("output error");
- exit(-1);
- }
- }
-
if (dev->binary) {
err = android_log_processBinaryLogBuffer(buf, &entry, g_eventTagMap,
binaryMsgBuf, sizeof(binaryMsgBuf));
@@ -192,15 +183,27 @@ static void processBuffer(log_device_t* dev, struct logger_entry *buf)
} else {
err = android_log_processLogBuffer(buf, &entry);
}
- if (err < 0)
+ if (err < 0) {
goto error;
+ }
+
+ if (android_log_shouldPrintLine(g_logformat, entry.tag, entry.priority)) {
+ if (false && g_devCount > 1) {
+ binaryMsgBuf[0] = dev->label;
+ binaryMsgBuf[1] = ' ';
+ bytesWritten = write(g_outFD, binaryMsgBuf, 2);
+ if (bytesWritten < 0) {
+ perror("output error");
+ exit(-1);
+ }
+ }
- bytesWritten = android_log_filterAndPrintLogLine(
- g_logformat, g_outFD, &entry);
+ bytesWritten = android_log_printLogLine(g_logformat, g_outFD, &entry);
- if (bytesWritten < 0) {
- perror("output error");
- exit(-1);
+ if (bytesWritten < 0) {
+ perror("output error");
+ exit(-1);
+ }
}
g_outByteCount += bytesWritten;
@@ -318,6 +321,10 @@ static void readLogLines(log_device_t* devices)
}
eatEntry(dev, entry);
}
+ // They requested to just dump the log
+ if (g_nonblock) {
+ exit(0);
+ }
} else {
// print all that aren't the last in their list
while (true) {
@@ -483,7 +490,7 @@ int main(int argc, char **argv)
break;
case 'd':
- mode |= O_NONBLOCK;
+ g_nonblock = true;
break;
case 'g':
@@ -638,8 +645,16 @@ int main(int argc, char **argv)
}
if (!devices) {
- devices = new log_device_t(strdup("/dev/"LOGGER_LOG_MAIN), false, LOGGER_LOG_MAIN[0]);
+ devices = new log_device_t(strdup("/dev/"LOGGER_LOG_MAIN), false, 'm');
android::g_devCount = 1;
+ int accessmode =
+ (mode & O_RDONLY) ? R_OK : 0
+ | (mode & O_WRONLY) ? W_OK : 0;
+ // only add this if it's available
+ if (0 == access("/dev/"LOGGER_LOG_SYSTEM, accessmode)) {
+ devices->next = new log_device_t(strdup("/dev/"LOGGER_LOG_SYSTEM), false, 's');
+ android::g_devCount++;
+ }
}
if (android::g_logRotateSizeKBytes != 0
@@ -714,7 +729,6 @@ int main(int argc, char **argv)
perror("ioctl");
exit(EXIT_FAILURE);
}
- return 0;
}
if (getLogSize) {
@@ -744,6 +758,9 @@ int main(int argc, char **argv)
if (getLogSize) {
return 0;
}
+ if (clearLog) {
+ return 0;
+ }
//LOG_EVENT_INT(10, 12345);
//LOG_EVENT_LONG(11, 0x1122334455667788LL);