summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2014-02-06 20:07:50 -0800
committerColin Cross <ccross@android.com>2014-02-09 21:59:24 -0800
commit810d19f99a724a929646502a1dd101acef00cd4f (patch)
tree1d2e0bb4d52e1838c1486a79a1ab9ef9b84a6872 /include
parent4207df11c5c09969b576324b4eea93a4c4e1ee99 (diff)
downloadsystem_core-810d19f99a724a929646502a1dd101acef00cd4f.zip
system_core-810d19f99a724a929646502a1dd101acef00cd4f.tar.gz
system_core-810d19f99a724a929646502a1dd101acef00cd4f.tar.bz2
log: add compile-time checking when ALOGV is disabled
Wrap the call in a if (0) when verbose logging is disabled to provide compile time checking. Also add a printf format attribute to the function to warn if parameters are incorrect. Change-Id: Ic77edeadcc4d886ca0f8b434f8550e18e22d5901
Diffstat (limited to 'include')
-rw-r--r--include/log/log.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/include/log/log.h b/include/log/log.h
index 7f952ff..d469f40 100644
--- a/include/log/log.h
+++ b/include/log/log.h
@@ -73,10 +73,11 @@ extern "C" {
* Simplified macro to send a verbose log message using the current LOG_TAG.
*/
#ifndef ALOGV
+#define __ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
#if LOG_NDEBUG
-#define ALOGV(...) ((void)0)
+#define ALOGV(...) do { if (0) { __ALOGV(__VA_ARGS__); } } while (0)
#else
-#define ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
+#define ALOGV(...) __ALOGV(__VA_ARGS__)
#endif
#endif
@@ -202,10 +203,11 @@ extern "C" {
* Simplified macro to send a verbose system log message using the current LOG_TAG.
*/
#ifndef SLOGV
+#define __SLOGV(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
#if LOG_NDEBUG
-#define SLOGV(...) ((void)0)
+#define SLOGV(...) do { if (0) { __SLOGV(__VA_ARGS__); } } while (0)
#else
-#define SLOGV(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
+#define SLOGV(...) __SLOGV(__VA_ARGS__)
#endif
#endif
@@ -284,10 +286,11 @@ extern "C" {
* Simplified macro to send a verbose radio log message using the current LOG_TAG.
*/
#ifndef RLOGV
+#define __RLOGV(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
#if LOG_NDEBUG
-#define RLOGV(...) ((void)0)
+#define RLOGV(...) do { if (0) { __RLOGV(__VA_ARGS__); } } while (0)
#else
-#define RLOGV(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
+#define RLOGV(...) __RLOGV(__VA_ARGS__)
#endif
#endif
@@ -557,7 +560,11 @@ typedef enum log_id {
* 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, ...);
+int __android_log_buf_print(int bufID, int prio, const char *tag, const char *fmt, ...)
+#if defined(__GNUC__)
+ __attribute__((__format__(printf, 4, 5)))
+#endif
+ ;
#ifdef __cplusplus
}