[84929][85032][85034]fix syslog set/get log level, default file count and size
Change-Id: I56929b9b4a403c15650656fcaa8eab428e4d33bf
diff --git a/mbtk/mbtk_logd/alog_read.c b/mbtk/mbtk_logd/alog_read.c
index 33f227f..061516d 100755
--- a/mbtk/mbtk_logd/alog_read.c
+++ b/mbtk/mbtk_logd/alog_read.c
@@ -12,6 +12,7 @@
#include "log_config.h"
#define ALOG_DEV "/dev/log_radio"
+#define LOG_CONFIG_LEN 50
typedef enum android_LogPriority {
ANDROID_LOG_UNKNOWN = 0,
@@ -36,7 +37,8 @@
const char * message;
} AndroidLogEntry;
-static const char *log_file, *log_ip, *log_port, *log_prefix, *pid_file, *hostname;
+//static const char *log_file, *log_ip, *log_port, *log_prefix, *pid_file, *hostname;
+static char log_file[LOG_CONFIG_LEN], log_ip[LOG_CONFIG_LEN], log_port[LOG_CONFIG_LEN], log_prefix[LOG_CONFIG_LEN], pid_file[LOG_CONFIG_LEN], hostname[LOG_CONFIG_LEN];
static int log_size = 1 * 1024 * 1024;
static log_config_entry *config = NULL;
@@ -243,13 +245,23 @@
memset(&file_list, 0, sizeof(struct file_list_t));
file_list.total = config->rotate_file_count;
- log_file = config->out_path;
+ //log_file = config->out_path;
+ memset(log_file, 0, sizeof(log_file));
+ memset(log_ip, 0, sizeof(log_ip));
+ memset(log_port, 0, sizeof(log_port));
+ memset(log_prefix, 0, sizeof(log_prefix));
+ memset(pid_file, 0, sizeof(pid_file));
+ memset(hostname, 0, sizeof(hostname));
+ if(config->out_path != NULL)
+ {
+ strncpy(log_file, config->out_path, LOG_CONFIG_LEN - 1);
+ }
if (config->ip && config->port) {
int port = atoi(config->port);
printf("%s %d : %s:%s\n", __FUNCTION__, __LINE__, config->ip, config->port);
log_fd = tcp_connect(config->ip, port);
- } else if (log_file) {
+ } else if (strlen(log_file) > 0) {
sprintf(tmp_log, "/tmp/log%s", strstr_tail(log_file, "/"));
// 先将文件保存到 /tmp/log/ 目录下,后面到达 rotate_file_size 后,转移到out_path
log_fd = open(tmp_log, O_CREAT | O_WRONLY| O_APPEND, 0600);