IPACM: enable logging only for debug builds

Make changes to enable DIAG logging only for debug builds
due to sepolicy.

Change-Id: I1ae3bee3a37069d6f9f2c3720f9c99cdc6ccb4e8
diff --git a/ipacm/inc/IPACM_Log.h b/ipacm/inc/IPACM_Log.h
index 131aab8..8fce44e 100644
--- a/ipacm/inc/IPACM_Log.h
+++ b/ipacm/inc/IPACM_Log.h
@@ -67,16 +67,16 @@
 static char buffer_send[MAX_BUF_LEN];
 static char dmesg_cmd[MAX_BUF_LEN];
 
-#define PERROR(fmt)   memset(buffer_send, 0, MAX_BUF_LEN);\
-					  snprintf(buffer_send,MAX_BUF_LEN,"%s:%d %s()", __FILE__, __LINE__, __FUNCTION__);\
-					  ipacm_log_send (buffer_send); \
-                      perror(fmt);
-
 #define IPACMDBG_DMESG(fmt, ...) memset(buffer_send, 0, MAX_BUF_LEN);\
 							     snprintf(buffer_send,MAX_BUF_LEN,"%s:%d %s: " fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);\
 								 memset(dmesg_cmd, 0, MAX_BUF_LEN);\
 								 snprintf(dmesg_cmd, MAX_BUF_LEN, "echo %s > /dev/kmsg", buffer_send);\
 								 system(dmesg_cmd);
+#ifdef DEBUG
+#define PERROR(fmt)   memset(buffer_send, 0, MAX_BUF_LEN);\
+					  snprintf(buffer_send,MAX_BUF_LEN,"%s:%d %s()", __FILE__, __LINE__, __FUNCTION__);\
+					  ipacm_log_send (buffer_send); \
+                      perror(fmt);
 #define IPACMERR(fmt, ...)	memset(buffer_send, 0, MAX_BUF_LEN);\
 							snprintf(buffer_send,MAX_BUF_LEN,"ERR: %s:%d %s() " fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);\
 							ipacm_log_send (buffer_send);\
@@ -85,6 +85,11 @@
 							 snprintf(buffer_send,MAX_BUF_LEN,"%s:%d %s() " fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);\
 							 ipacm_log_send (buffer_send);\
 							 printf("%s:%d %s() " fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);
+#else
+#define PERROR(fmt)   perror(fmt)
+#define IPACMERR(fmt, ...)   printf("ERR: %s:%d %s() " fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);
+#define IPACMDBG_H(fmt, ...) printf("%s:%d %s() " fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);
+#endif
 #define IPACMDBG(fmt, ...)	printf("%s:%d %s() " fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);
 #define IPACMLOG(fmt, ...)  printf(fmt, ##__VA_ARGS__);
 
diff --git a/ipacm/src/Android.mk b/ipacm/src/Android.mk
index c52a8a4..ed5bc5b 100644
--- a/ipacm/src/Android.mk
+++ b/ipacm/src/Android.mk
@@ -27,8 +27,9 @@
 
 LOCAL_CFLAGS := -v
 LOCAL_CFLAGS += -DFEATURE_IPA_ANDROID
+ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
 LOCAL_CFLAGS += -DDEBUG
-
+endif
 filetoadd = bionic/libc/kernel/arch-arm/asm/posix_types.h
 LOCAL_CFLAGS += $(shell if [ -a $(filetoadd) ] ; then echo -include $(filetoadd) ; fi ;)
 filetoadd = bionic/libc/kernel/arch-arm/asm/byteorder.h