Loading include/cutils/log.h +100 −0 Original line number Diff line number Diff line Loading @@ -196,6 +196,91 @@ extern "C" { #define IF_LOGE() IF_LOG(LOG_ERROR, LOG_TAG) #endif // --------------------------------------------------------------------- /* * Simplified macro to send a verbose system log message using the current LOG_TAG. */ #ifndef SLOGV #if LOG_NDEBUG #define SLOGV(...) ((void)0) #else #define SLOGV(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) #endif #endif #define CONDITION(cond) (__builtin_expect((cond)!=0, 0)) #ifndef SLOGV_IF #if LOG_NDEBUG #define SLOGV_IF(cond, ...) ((void)0) #else #define SLOGV_IF(cond, ...) \ ( (CONDITION(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif #endif /* * Simplified macro to send a debug system log message using the current LOG_TAG. */ #ifndef SLOGD #define SLOGD(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) #endif #ifndef SLOGD_IF #define SLOGD_IF(cond, ...) \ ( (CONDITION(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif /* * Simplified macro to send an info system log message using the current LOG_TAG. */ #ifndef SLOGI #define SLOGI(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) #endif #ifndef SLOGI_IF #define SLOGI_IF(cond, ...) \ ( (CONDITION(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif /* * Simplified macro to send a warning system log message using the current LOG_TAG. */ #ifndef SLOGW #define SLOGW(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) #endif #ifndef SLOGW_IF #define SLOGW_IF(cond, ...) \ ( (CONDITION(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif /* * Simplified macro to send an error system log message using the current LOG_TAG. */ #ifndef SLOGE #define SLOGE(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) #endif #ifndef SLOGE_IF #define SLOGE_IF(cond, ...) \ ( (CONDITION(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif // --------------------------------------------------------------------- /* Loading Loading @@ -338,6 +423,21 @@ typedef enum { #define android_logToFile(tag, file) (0) #define android_logToFd(tag, fd) (0) typedef enum { LOG_ID_MAIN = 0, LOG_ID_RADIO = 1, LOG_ID_EVENTS = 2, LOG_ID_SYSTEM = 3, LOG_ID_MAX } log_id_t; /* * Send a simple string to the log. */ int __android_log_buf_write(int bufID, int prio, const char *tag, const char *text); int __android_log_buf_print(int bufID, int prio, const char *tag, const char *fmt, ...); #ifdef __cplusplus } Loading include/cutils/logger.h +1 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ struct logger_entry { #define LOGGER_LOG_MAIN "log/main" #define LOGGER_LOG_RADIO "log/radio" #define LOGGER_LOG_EVENTS "log/events" #define LOGGER_LOG_SYSTEM "log/system" #define LOGGER_ENTRY_MAX_LEN (4*1024) #define LOGGER_ENTRY_MAX_PAYLOAD \ Loading include/cutils/logprint.h +1 −1 Original line number Diff line number Diff line Loading @@ -142,7 +142,7 @@ char *android_log_formatLogLine ( * Assumes single threaded execution * */ int android_log_filterAndPrintLogLine( int android_log_printLogLine( AndroidLogFormat *p_format, int fd, const AndroidLogEntry *entry); Loading liblog/logd_write.c +51 −11 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include <cutils/logger.h> #include <cutils/logd.h> #include <cutils/log.h> #define LOG_BUF_SIZE 1024 Loading @@ -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 Loading Loading @@ -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; Loading @@ -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 Loading Loading @@ -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]; Loading @@ -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, ...) { Loading liblog/logprint.c +1 −6 Original line number Diff line number Diff line Loading @@ -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) Loading @@ -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); Loading Loading
include/cutils/log.h +100 −0 Original line number Diff line number Diff line Loading @@ -196,6 +196,91 @@ extern "C" { #define IF_LOGE() IF_LOG(LOG_ERROR, LOG_TAG) #endif // --------------------------------------------------------------------- /* * Simplified macro to send a verbose system log message using the current LOG_TAG. */ #ifndef SLOGV #if LOG_NDEBUG #define SLOGV(...) ((void)0) #else #define SLOGV(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) #endif #endif #define CONDITION(cond) (__builtin_expect((cond)!=0, 0)) #ifndef SLOGV_IF #if LOG_NDEBUG #define SLOGV_IF(cond, ...) ((void)0) #else #define SLOGV_IF(cond, ...) \ ( (CONDITION(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif #endif /* * Simplified macro to send a debug system log message using the current LOG_TAG. */ #ifndef SLOGD #define SLOGD(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) #endif #ifndef SLOGD_IF #define SLOGD_IF(cond, ...) \ ( (CONDITION(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif /* * Simplified macro to send an info system log message using the current LOG_TAG. */ #ifndef SLOGI #define SLOGI(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) #endif #ifndef SLOGI_IF #define SLOGI_IF(cond, ...) \ ( (CONDITION(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif /* * Simplified macro to send a warning system log message using the current LOG_TAG. */ #ifndef SLOGW #define SLOGW(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) #endif #ifndef SLOGW_IF #define SLOGW_IF(cond, ...) \ ( (CONDITION(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif /* * Simplified macro to send an error system log message using the current LOG_TAG. */ #ifndef SLOGE #define SLOGE(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) #endif #ifndef SLOGE_IF #define SLOGE_IF(cond, ...) \ ( (CONDITION(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif // --------------------------------------------------------------------- /* Loading Loading @@ -338,6 +423,21 @@ typedef enum { #define android_logToFile(tag, file) (0) #define android_logToFd(tag, fd) (0) typedef enum { LOG_ID_MAIN = 0, LOG_ID_RADIO = 1, LOG_ID_EVENTS = 2, LOG_ID_SYSTEM = 3, LOG_ID_MAX } log_id_t; /* * Send a simple string to the log. */ int __android_log_buf_write(int bufID, int prio, const char *tag, const char *text); int __android_log_buf_print(int bufID, int prio, const char *tag, const char *fmt, ...); #ifdef __cplusplus } Loading
include/cutils/logger.h +1 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ struct logger_entry { #define LOGGER_LOG_MAIN "log/main" #define LOGGER_LOG_RADIO "log/radio" #define LOGGER_LOG_EVENTS "log/events" #define LOGGER_LOG_SYSTEM "log/system" #define LOGGER_ENTRY_MAX_LEN (4*1024) #define LOGGER_ENTRY_MAX_PAYLOAD \ Loading
include/cutils/logprint.h +1 −1 Original line number Diff line number Diff line Loading @@ -142,7 +142,7 @@ char *android_log_formatLogLine ( * Assumes single threaded execution * */ int android_log_filterAndPrintLogLine( int android_log_printLogLine( AndroidLogFormat *p_format, int fd, const AndroidLogEntry *entry); Loading
liblog/logd_write.c +51 −11 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include <cutils/logger.h> #include <cutils/logd.h> #include <cutils/log.h> #define LOG_BUF_SIZE 1024 Loading @@ -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 Loading Loading @@ -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; Loading @@ -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 Loading Loading @@ -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]; Loading @@ -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, ...) { Loading
liblog/logprint.c +1 −6 Original line number Diff line number Diff line Loading @@ -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) Loading @@ -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); Loading