Loading liblog/fake_log_device.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -516,13 +516,12 @@ void FakeClose() { memset(&log_state, 0, sizeof(log_state)); } int __android_log_is_loggable(int prio, const char*, int def) { int __android_log_is_loggable(int prio, const char*, int) { int minimum_priority = __android_log_get_minimum_priority(); if (minimum_priority == ANDROID_LOG_DEFAULT) { return prio >= def; } else { return prio >= minimum_priority; minimum_priority = ANDROID_LOG_INFO; } return prio >= minimum_priority; } int __android_log_is_loggable_len(int prio, const char*, size_t, int def) { Loading liblog/include/android/log.h +4 −0 Original line number Diff line number Diff line Loading @@ -194,6 +194,10 @@ struct __android_logger_data { * Writes the log message specified with logger_data and msg to the log. logger_data includes * additional file name and line number information that a logger may use. logger_data is versioned * for backwards compatibility. * This assumes that loggability has already been checked through __android_log_is_loggable(). * Higher level logging libraries, such as libbase, first check loggability, then format their * buffers, then pass the message to liblog via this function, and therefore we do not want to * duplicate the loggability check here. */ void __android_log_write_logger_data(struct __android_logger_data* logger_data, const char* msg); Loading liblog/logger_write.cpp +27 −12 Original line number Diff line number Diff line Loading @@ -185,15 +185,6 @@ static int write_to_log(log_id_t log_id, struct iovec* vec, size_t nr) { errno = save_errno; return -EINVAL; } } else { int prio = *static_cast<int*>(vec[0].iov_base); const char* tag = static_cast<const char*>(vec[1].iov_base); size_t len = vec[1].iov_len; if (!__android_log_is_loggable_len(prio, tag, len - 1, ANDROID_LOG_VERBOSE)) { errno = save_errno; return -EPERM; } } ret = LogdWrite(log_id, &ts, vec, nr); Loading Loading @@ -292,20 +283,35 @@ void __android_log_write_logger_data(__android_logger_data* logger_data, const c } int __android_log_buf_write(int bufID, int prio, const char* tag, const char* msg) { if (!__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE)) { return 0; } __android_logger_data logger_data = {sizeof(__android_logger_data), bufID, prio, tag, nullptr, 0}; __android_log_write_logger_data(&logger_data, msg); return 1; } int __android_log_vprint(int prio, const char* tag, const char* fmt, va_list ap) { if (!__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE)) { return 0; } char buf[LOG_BUF_SIZE]; vsnprintf(buf, LOG_BUF_SIZE, fmt, ap); return __android_log_write(prio, tag, buf); __android_logger_data logger_data = { sizeof(__android_logger_data), LOG_ID_MAIN, prio, tag, nullptr, 0}; __android_log_write_logger_data(&logger_data, buf); return 1; } int __android_log_print(int prio, const char* tag, const char* fmt, ...) { if (!__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE)) { return 0; } va_list ap; char buf[LOG_BUF_SIZE]; Loading @@ -313,10 +319,17 @@ int __android_log_print(int prio, const char* tag, const char* fmt, ...) { vsnprintf(buf, LOG_BUF_SIZE, fmt, ap); va_end(ap); return __android_log_write(prio, tag, buf); __android_logger_data logger_data = { sizeof(__android_logger_data), LOG_ID_MAIN, prio, tag, nullptr, 0}; __android_log_write_logger_data(&logger_data, buf); return 1; } int __android_log_buf_print(int bufID, int prio, const char* tag, const char* fmt, ...) { if (!__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE)) { return 0; } va_list ap; char buf[LOG_BUF_SIZE]; Loading @@ -324,7 +337,9 @@ int __android_log_buf_print(int bufID, int prio, const char* tag, const char* fm vsnprintf(buf, LOG_BUF_SIZE, fmt, ap); va_end(ap); return __android_log_buf_write(bufID, prio, tag, buf); __android_logger_data logger_data = {sizeof(__android_logger_data), bufID, prio, tag, nullptr, 0}; __android_log_write_logger_data(&logger_data, buf); return 1; } void __android_log_assert(const char* cond, const char* tag, const char* fmt, ...) { Loading Loading
liblog/fake_log_device.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -516,13 +516,12 @@ void FakeClose() { memset(&log_state, 0, sizeof(log_state)); } int __android_log_is_loggable(int prio, const char*, int def) { int __android_log_is_loggable(int prio, const char*, int) { int minimum_priority = __android_log_get_minimum_priority(); if (minimum_priority == ANDROID_LOG_DEFAULT) { return prio >= def; } else { return prio >= minimum_priority; minimum_priority = ANDROID_LOG_INFO; } return prio >= minimum_priority; } int __android_log_is_loggable_len(int prio, const char*, size_t, int def) { Loading
liblog/include/android/log.h +4 −0 Original line number Diff line number Diff line Loading @@ -194,6 +194,10 @@ struct __android_logger_data { * Writes the log message specified with logger_data and msg to the log. logger_data includes * additional file name and line number information that a logger may use. logger_data is versioned * for backwards compatibility. * This assumes that loggability has already been checked through __android_log_is_loggable(). * Higher level logging libraries, such as libbase, first check loggability, then format their * buffers, then pass the message to liblog via this function, and therefore we do not want to * duplicate the loggability check here. */ void __android_log_write_logger_data(struct __android_logger_data* logger_data, const char* msg); Loading
liblog/logger_write.cpp +27 −12 Original line number Diff line number Diff line Loading @@ -185,15 +185,6 @@ static int write_to_log(log_id_t log_id, struct iovec* vec, size_t nr) { errno = save_errno; return -EINVAL; } } else { int prio = *static_cast<int*>(vec[0].iov_base); const char* tag = static_cast<const char*>(vec[1].iov_base); size_t len = vec[1].iov_len; if (!__android_log_is_loggable_len(prio, tag, len - 1, ANDROID_LOG_VERBOSE)) { errno = save_errno; return -EPERM; } } ret = LogdWrite(log_id, &ts, vec, nr); Loading Loading @@ -292,20 +283,35 @@ void __android_log_write_logger_data(__android_logger_data* logger_data, const c } int __android_log_buf_write(int bufID, int prio, const char* tag, const char* msg) { if (!__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE)) { return 0; } __android_logger_data logger_data = {sizeof(__android_logger_data), bufID, prio, tag, nullptr, 0}; __android_log_write_logger_data(&logger_data, msg); return 1; } int __android_log_vprint(int prio, const char* tag, const char* fmt, va_list ap) { if (!__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE)) { return 0; } char buf[LOG_BUF_SIZE]; vsnprintf(buf, LOG_BUF_SIZE, fmt, ap); return __android_log_write(prio, tag, buf); __android_logger_data logger_data = { sizeof(__android_logger_data), LOG_ID_MAIN, prio, tag, nullptr, 0}; __android_log_write_logger_data(&logger_data, buf); return 1; } int __android_log_print(int prio, const char* tag, const char* fmt, ...) { if (!__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE)) { return 0; } va_list ap; char buf[LOG_BUF_SIZE]; Loading @@ -313,10 +319,17 @@ int __android_log_print(int prio, const char* tag, const char* fmt, ...) { vsnprintf(buf, LOG_BUF_SIZE, fmt, ap); va_end(ap); return __android_log_write(prio, tag, buf); __android_logger_data logger_data = { sizeof(__android_logger_data), LOG_ID_MAIN, prio, tag, nullptr, 0}; __android_log_write_logger_data(&logger_data, buf); return 1; } int __android_log_buf_print(int bufID, int prio, const char* tag, const char* fmt, ...) { if (!__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE)) { return 0; } va_list ap; char buf[LOG_BUF_SIZE]; Loading @@ -324,7 +337,9 @@ int __android_log_buf_print(int bufID, int prio, const char* tag, const char* fm vsnprintf(buf, LOG_BUF_SIZE, fmt, ap); va_end(ap); return __android_log_buf_write(bufID, prio, tag, buf); __android_logger_data logger_data = {sizeof(__android_logger_data), bufID, prio, tag, nullptr, 0}; __android_log_write_logger_data(&logger_data, buf); return 1; } void __android_log_assert(const char* cond, const char* tag, const char* fmt, ...) { Loading