diff options
author | Joe Onorato <joeo@android.com> | 2010-03-01 09:11:54 -0800 |
---|---|---|
committer | Joe Onorato <joeo@android.com> | 2010-03-01 13:03:19 -0800 |
commit | e2bf2ea4d2846031edfc52b942ad53e5467243f6 (patch) | |
tree | 76fa7dca61684d78c93755986db60a3a6d3731e4 /liblog | |
parent | b91bf4ba864a392412397913ee09a8c1f2e7cc87 (diff) | |
download | core-e2bf2ea4d2846031edfc52b942ad53e5467243f6.tar.gz core-e2bf2ea4d2846031edfc52b942ad53e5467243f6.tar.bz2 core-e2bf2ea4d2846031edfc52b942ad53e5467243f6.zip |
Make logcat print both the main and system buffers by default. Make SLOGx macros work.
Diffstat (limited to 'liblog')
-rw-r--r-- | liblog/logd_write.c | 62 | ||||
-rw-r--r-- | liblog/logprint.c | 7 |
2 files changed, 52 insertions, 17 deletions
diff --git a/liblog/logd_write.c b/liblog/logd_write.c index 241dbf0c7..49ceb9221 100644 --- a/liblog/logd_write.c +++ b/liblog/logd_write.c @@ -27,6 +27,7 @@ #include <cutils/logger.h> #include <cutils/logd.h> +#include <cutils/log.h> #define LOG_BUF_SIZE 1024 @@ -41,21 +42,13 @@ #define log_close(filedes) close(filedes) #endif -typedef enum { - LOG_ID_MAIN = 0, - LOG_ID_RADIO, - LOG_ID_EVENTS, - LOG_ID_MAX -} log_id_t; - static int __write_to_log_init(log_id_t, struct iovec *vec, size_t nr); -static int (*write_to_log)(log_id_t, struct iovec *vec, size_t nr) = - __write_to_log_init; +static int (*write_to_log)(log_id_t, struct iovec *vec, size_t nr) = __write_to_log_init; #ifdef HAVE_PTHREADS static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER; #endif -static int log_fds[(int)LOG_ID_MAX] = { -1, -1, -1 }; +static int log_fds[(int)LOG_ID_MAX] = { -1, -1, -1, -1 }; /* * This is used by the C++ code to decide if it should write logs through @@ -110,6 +103,7 @@ static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr) log_fds[LOG_ID_MAIN] = log_open("/dev/"LOGGER_LOG_MAIN, O_WRONLY); log_fds[LOG_ID_RADIO] = log_open("/dev/"LOGGER_LOG_RADIO, O_WRONLY); log_fds[LOG_ID_EVENTS] = log_open("/dev/"LOGGER_LOG_EVENTS, O_WRONLY); + log_fds[LOG_ID_SYSTEM] = log_open("/dev/"LOGGER_LOG_SYSTEM, O_WRONLY); write_to_log = __write_to_log_kernel; @@ -123,6 +117,12 @@ static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr) log_fds[LOG_ID_EVENTS] = -1; write_to_log = __write_to_log_null; } + + printf("LOG_ID_SYSTEM=%d\n", log_fds[LOG_ID_SYSTEM]); + printf("LOG_ID_MAIN=%d\n", log_fds[LOG_ID_MAIN]); + if (log_fds[LOG_ID_SYSTEM] < 0) { + log_fds[LOG_ID_SYSTEM] = log_fds[LOG_ID_MAIN]; + } } #ifdef HAVE_PTHREADS @@ -161,6 +161,34 @@ int __android_log_write(int prio, const char *tag, const char *msg) return write_to_log(log_id, vec, 3); } +int __android_log_buf_write(int bufID, int prio, const char *tag, const char *msg) +{ + struct iovec vec[3]; + + if (!tag) + tag = ""; + + /* XXX: This needs to go! */ + if (!strcmp(tag, "HTC_RIL") || + !strncmp(tag, "RIL", 3) || /* Any log tag with "RIL" as the prefix */ + !strcmp(tag, "AT") || + !strcmp(tag, "GSM") || + !strcmp(tag, "STK") || + !strcmp(tag, "CDMA") || + !strcmp(tag, "PHONE") || + !strcmp(tag, "SMS")) + bufID = LOG_ID_RADIO; + + vec[0].iov_base = (unsigned char *) &prio; + vec[0].iov_len = 1; + vec[1].iov_base = (void *) tag; + vec[1].iov_len = strlen(tag) + 1; + vec[2].iov_base = (void *) msg; + vec[2].iov_len = strlen(msg) + 1; + + return write_to_log(bufID, vec, 3); +} + int __android_log_vprint(int prio, const char *tag, const char *fmt, va_list ap) { char buf[LOG_BUF_SIZE]; @@ -173,7 +201,7 @@ int __android_log_vprint(int prio, const char *tag, const char *fmt, va_list ap) int __android_log_print(int prio, const char *tag, const char *fmt, ...) { va_list ap; - char buf[LOG_BUF_SIZE]; + char buf[LOG_BUF_SIZE]; va_start(ap, fmt); vsnprintf(buf, LOG_BUF_SIZE, fmt, ap); @@ -182,6 +210,18 @@ int __android_log_print(int prio, const char *tag, const char *fmt, ...) return __android_log_write(prio, tag, buf); } +int __android_log_buf_print(int bufID, int prio, const char *tag, const char *fmt, ...) +{ + va_list ap; + char buf[LOG_BUF_SIZE]; + + va_start(ap, fmt); + vsnprintf(buf, LOG_BUF_SIZE, fmt, ap); + va_end(ap); + + return __android_log_buf_write(bufID, prio, tag, buf); +} + void __android_log_assert(const char *cond, const char *tag, const char *fmt, ...) { diff --git a/liblog/logprint.c b/liblog/logprint.c index 080f9e364..5ddda3626 100644 --- a/liblog/logprint.c +++ b/liblog/logprint.c @@ -840,7 +840,7 @@ char *android_log_formatLogLine ( * Returns count bytes written */ -int android_log_filterAndPrintLogLine( +int android_log_printLogLine( AndroidLogFormat *p_format, int fd, const AndroidLogEntry *entry) @@ -850,11 +850,6 @@ int android_log_filterAndPrintLogLine( char *outBuffer = NULL; size_t totalLen; - if (0 == android_log_shouldPrintLine(p_format, entry->tag, - entry->priority)) { - return 0; - } - outBuffer = android_log_formatLogLine(p_format, defaultBuffer, sizeof(defaultBuffer), entry, &totalLen); |