| diff --git a/system/core/liblog/logger_write.c b/system/core/liblog/logger_write.c |
| index 3061862d7c..2c0ab0dafd 100644 |
| --- a/system/core/liblog/logger_write.c |
| +++ b/system/core/liblog/logger_write.c |
| @@ -33,10 +33,10 @@ |
| |
| #define __REDIRECT_TO_SYSLOGD__ |
| |
| -#if defined(__REDIRECT_TO_SYSLOGD__) |
| +#ifdef __REDIRECT_TO_SYSLOGD__ |
| +#include <stdio.h> |
| #include <syslog.h> |
| #include <sys/syscall.h> |
| -#include <unistd.h> |
| #endif |
| |
| #include "config_write.h" |
| @@ -508,6 +507,42 @@ static int __write_to_log_daemon(log_id_t log_id, struct iovec *vec, size_t nr) |
| return ret; |
| } |
| |
| +#if defined(__REDIRECT_TO_SYSLOGD__) |
| +static bool isUserLoad() { |
| + FILE *fp; |
| + char* buffer = NULL; |
| + size_t buffer_size = 0; |
| + bool isUser = false; |
| + |
| + if ((fp = popen("/bin/getprop ro.build.type", "r")) == NULL) { |
| + syslog(LOG_ERR, "open build.prop failed"); |
| + return false; |
| + } |
| + |
| + buffer = (char*)calloc(32, sizeof(char)); |
| + if (buffer == NULL) { |
| + syslog(LOG_ERR, "malloc buffer failed"); |
| + pclose(fp); |
| + return false; |
| + } |
| + |
| + while(getline(&buffer, &buffer_size, fp) != -1) { |
| + if ((buffer_size != 0) && strstr(buffer, "user")) { |
| + isUser = true; |
| + break; |
| + } |
| + } |
| + |
| + if (buffer != NULL) { |
| + free(buffer); |
| + } |
| + if (fp != NULL) { |
| + pclose(fp); |
| + } |
| + return isUser; |
| +} |
| +#endif |
| + |
| static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr) |
| { |
| __android_log_lock(); |
| @@ -534,6 +569,12 @@ static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr) |
| } |
| } else { |
| openlog("ALOG", 0, LOG_USER); |
| + |
| + // if user load, set log mask up to error |
| + if (isUserLoad()) { |
| + // set log mask to error |
| + setlogmask(LOG_UPTO(LOG_INFO)); |
| + } |
| } |
| #else |
| ret = __write_to_log_initialize(); |