[Bugfix][T106][bug-view-928]Fixed the issue of serial port printing when print_1evel=4

Only Configure :No
Affected branch:master
Affected module:log
Is it affected on both ZXIC and MTK:only ZXIC
Self-test: Yes
Doc Update: No

Change-Id: I1d606c6f61dd5cf96017555c411d79ee46c52091
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/binder/liblog/logd_write.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/binder/liblog/logd_write.c
index 8e86270..8483024 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/binder/liblog/logd_write.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/binder/liblog/logd_write.c
@@ -54,6 +54,10 @@
 #include "fake_log_device.h"
 #endif
 
+/*cz.li add on 2024/7/8 for control RLOGD start*/
+int sys_log_levle = 1;
+int print_log_level = 1;
+/*cz.li add on 2024/7/8 for control RLOGD end*/
 //??¨¨??¨¤o??¨´¡Á?¨º¡À??
 long long int get_time_us()
 {
@@ -158,11 +162,11 @@
 				break;
 		}
 	}
-
-	if (prio >= ANDROID_LOG_DEBUG && ANDROID_LOG_ERROR >= prio) {
+/*cz.li add on 2024/7/8 for control RLOGD start*/
+	if (prio >= ANDROID_LOG_DEBUG && ANDROID_LOG_ERROR >= prio && prio >= print_log_level) {
 		put_to_console(mod, fmt, arg);
 	}
-
+/*cz.li add on 2024/7/8 for control RLOGD end*/
 	return ret;
 }
 
@@ -440,7 +444,39 @@
     return LOG_NAME[log_id];
 }
 #endif
-int sys_log_levle = 4;
+/*cz.li add on 2025/1/3 for control log_level start*/
+int log_level(char *level_name)
+{
+    char nv_level[10];
+    char buffer[32];
+    char cmd[128];
+    int *level = NULL;
+    sprintf(cmd, "nv show | grep %s",level_name);
+    FILE *output = popen(cmd, "r");
+    while (fgets(buffer, sizeof(buffer), output) != NULL)
+    {
+        char *equal_sign = strchr(buffer, '=');
+        strncpy(nv_level,equal_sign + 1,1);
+    }
+    pclose(output);
+    nv_level[sizeof(nv_level)-1] = '\0';
+    if (strcmp(level_name,"syslog_level") == 0)
+        level = &sys_log_levle;
+    else if (strcmp(level_name,"print_level") == 0)
+        level = &print_log_level;
+    *level = atoi(nv_level);
+    if(*level == SLOG_DEBUG)
+        *level = ANDROID_LOG_DEBUG;
+    else if(*level == SLOG_NORMAL)
+        *level = ANDROID_LOG_INFO;
+    else if(*level == SLOG_ERR)
+        *level = ANDROID_LOG_ERROR;
+    else if(*level== SLOG_OFF)
+        *level = ANDROID_LOG_SILENT;
+    else
+        *level = ANDROID_LOG_INFO;
+}
+/*cz.li add on 2025/1/3 for control log_level end*/
 static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr)
 {
 #ifdef HAVE_PTHREADS
@@ -467,36 +503,8 @@
     pthread_mutex_unlock(&log_init_lock);
 #endif
 /*cz.li add on 2024/7/8 for control RLOGD start*/    
-    char nv_syslog_level[10];
-    char buffer[32];
-    FILE *output = popen("nv show | grep syslog_level", "r");
-    while (fgets(buffer, sizeof(buffer), output) != NULL)
-    {
-        char *equal_sign = strchr(buffer, '=');
-        strncpy(nv_syslog_level,equal_sign + 1,1);
-    }
-    pclose(output);
-    sys_log_levle = atoi(nv_syslog_level);
-    if(sys_log_levle == SLOG_DEBUG)
-    {
-        sys_log_levle = ANDROID_LOG_DEBUG;
-    }
-    else if(sys_log_levle == SLOG_NORMAL)
-    {
-        sys_log_levle = ANDROID_LOG_INFO;
-    }
-    else if(sys_log_levle == SLOG_ERR)
-    {
-        sys_log_levle = ANDROID_LOG_ERROR;
-    }
-    else if(sys_log_levle == SLOG_OFF)
-    {
-        sys_log_levle = ANDROID_LOG_SILENT;
-    }
-    else
-    {
-        sys_log_levle = ANDROID_LOG_INFO;
-    }
+    log_level("syslog_level");
+    log_level("print_level");
 /*cz.li add on 2024/7/8 for control RLOGD end*/
     return write_to_log(log_id, vec, nr);
 }