parent
a9e2537777
commit
cdd5435c4e
|
@ -24,7 +24,7 @@ ret_code log_rpc_exec(char* service_name, char* method_name, pointer input, int
|
|||
}
|
||||
|
||||
|
||||
/* 仅适用于以“key=value”方式保存的配置解析,适用于log-sched.conf的解析 */
|
||||
/* 仅适用于以“key=value”方式保存的配置解析,适用于log-sched.conf的解析 */
|
||||
ret_code cm_log_get_keyvalue_from_file(const char *file_str, const char *key_str, char *value_str, int value_len)
|
||||
{
|
||||
ret_code ret = RET_ERR;
|
||||
|
@ -57,10 +57,10 @@ ret_code cm_log_get_keyvalue_from_file(const char *file_str, const char *key_str
|
|||
pos = strstr(line, key_str);
|
||||
if (pos != NULL)
|
||||
{
|
||||
/* 跳过key与value间的"=" */
|
||||
/* 跳过key与value间的"=" */
|
||||
strcpy(value_str, pos+strlen(key_str)+1);
|
||||
|
||||
/* 滤除掉段尾的回车换行 */
|
||||
/* 滤除掉段尾的回车换行 */
|
||||
if ('\n' == value_str[strlen(value_str)-1])
|
||||
{
|
||||
value_str[strlen(value_str)-1] = '\0';
|
||||
|
@ -80,7 +80,7 @@ ret_code cm_log_get_keyvalue_from_file(const char *file_str, const char *key_str
|
|||
}
|
||||
|
||||
|
||||
/* 检查的文件存在,本函数返回1,否则,本函数返回0 */
|
||||
/* 检查的文件存在,本函数返回1,否则,本函数返回0 */
|
||||
int cm_log_check_file_is_exist(const char *file_str)
|
||||
{
|
||||
int is_exist = 0;
|
||||
|
@ -91,7 +91,7 @@ int cm_log_check_file_is_exist(const char *file_str)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* 如果文件存在,access返回0,不存在,access返回-1 */
|
||||
/* 如果文件存在,access返回0,不存在,access返回-1 */
|
||||
is_exist = ((access(file_str, 0) == 0) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ int cm_log_check_file_is_exist(const char *file_str)
|
|||
}
|
||||
|
||||
|
||||
/* 适用于log-console.conf与log-pty.conf的解析 */
|
||||
/* 适用于log-console.conf与log-pty.conf的解析 */
|
||||
ret_code cm_log_get_module_from_file(const char *file_str, char *value_str, int value_len)
|
||||
{
|
||||
ret_code ret = RET_ERR;
|
||||
|
@ -154,7 +154,7 @@ ret_code cm_log_get_module_from_file(const char *file_str, char *value_str, int
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* 适用于log-console.conf与log-pty.conf的解析 */
|
||||
/* 适用于log-console.conf与log-pty.conf的解析 */
|
||||
ret_code cm_log_get_level_from_file(const char *file_str, u8 *value)
|
||||
{
|
||||
ret_code ret = RET_ERR;
|
||||
|
|
|
@ -38,9 +38,9 @@ static ret_code cm_get_log_file_elems(log_file_t *log_file_conf, int *err_no)
|
|||
|
||||
memset(log_file_conf, 0, sizeof(*log_file_conf));
|
||||
|
||||
/* level、path、is_compress、del_over_days暂未实现 */
|
||||
/* level、path、is_compress、del_over_days暂未实现 */
|
||||
|
||||
/* 日志文件大小上限:del_over_size */
|
||||
/* 日志文件大小上限:del_over_size */
|
||||
memset(value, 0, MAX_LINE_SZ);
|
||||
if (cm_log_get_keyvalue_from_file(CM_LOG_CONF_LOGFILE_FILE, LOG_CONF_KEY_FILE_MAX_SIZE_STR, value, sizeof(value)) == 0)
|
||||
{
|
||||
|
|
|
@ -166,7 +166,7 @@ static ret_code cm_log_prase_host_from_str(char *const input_str, log_remote_hos
|
|||
|
||||
memset(tmp_str, 0, sizeof(tmp_str));
|
||||
|
||||
/* 提取日志等级 */
|
||||
/* 提取日志等级 */
|
||||
while (1)
|
||||
{
|
||||
pos2 = strstr(pos, ".=");
|
||||
|
@ -202,7 +202,7 @@ static ret_code cm_log_prase_host_from_str(char *const input_str, log_remote_hos
|
|||
}
|
||||
ret_host->level = (u8)tmp_value;
|
||||
|
||||
/* 提取IP地址 */
|
||||
/* 提取IP地址 */
|
||||
pos = strstr(pos2, "@");
|
||||
if (NULL == pos)
|
||||
{
|
||||
|
@ -230,7 +230,7 @@ static ret_code cm_log_prase_host_from_str(char *const input_str, log_remote_hos
|
|||
strncpy(ret_host->host, pos, tmp_len);
|
||||
|
||||
|
||||
/* 提取端口 */
|
||||
/* 提取端口 */
|
||||
pos2 ++;
|
||||
pos = pos2;
|
||||
pos2 = strstr(pos, ":");
|
||||
|
@ -250,7 +250,7 @@ static ret_code cm_log_prase_host_from_str(char *const input_str, log_remote_hos
|
|||
}
|
||||
ret_host->port = (u16)tmp_value;
|
||||
|
||||
/* 提取日志存放格式 */
|
||||
/* 提取日志存放格式 */
|
||||
pos2++;
|
||||
pos = pos2;
|
||||
|
||||
|
@ -415,7 +415,7 @@ static ret_code cm_log_getall_host_from_file(const char *file_str, log_remote_ho
|
|||
|
||||
if (hosts[cnt].host[0] == '\0')
|
||||
{
|
||||
/* 无效数据 */
|
||||
/* 无效数据 */
|
||||
memset(hosts+cnt, 0, sizeof(log_remote_host_x_t));
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -84,8 +84,8 @@ static void logging_usage()
|
|||
fprintf(stdout, " %s %s <level>\n", LOGGING_MODULE_NAME, g_log_cmd[3].cmd);
|
||||
fprintf(stdout, " %s %s get\n", LOGGING_MODULE_NAME, g_log_cmd[3].cmd);
|
||||
fprintf(stdout, " <level> = emerg | alert | crit | err | warn | notice | info | debug \n");
|
||||
fprintf(stdout, " eg: %s %s info\n", LOGGING_MODULE_NAME, g_log_cmd[3].cmd);
|
||||
fprintf(stdout, " %s %s get\n", LOGGING_MODULE_NAME, g_log_cmd[3].cmd);
|
||||
fprintf(stdout, " eg: %s %s info\n", LOGGING_MODULE_NAME, g_log_cmd[3].cmd);
|
||||
fprintf(stdout, " %s %s get\n", LOGGING_MODULE_NAME, g_log_cmd[3].cmd);
|
||||
fprintf(stdout, "\n");
|
||||
|
||||
fprintf(stdout, "5. usage of %s %s:\n", LOGGING_MODULE_NAME, g_log_cmd[4].cmd);
|
||||
|
@ -96,8 +96,8 @@ static void logging_usage()
|
|||
fprintf(stdout, " <is_compress> = 0 | 1 , which 0 is syslog files is not compress while 1 is compress\n");
|
||||
fprintf(stdout, " <del_over_days> is the syslog files life-time (days)\n");
|
||||
fprintf(stdout, " <del_over_size> is the syslog files life-size (bytes)\n");
|
||||
fprintf(stdout, " eg: %s %s info /var/log/syslog-files 0 100 1024000\n", LOGGING_MODULE_NAME, g_log_cmd[4].cmd);
|
||||
fprintf(stdout, " %s %s get\n", LOGGING_MODULE_NAME, g_log_cmd[4].cmd);
|
||||
fprintf(stdout, " eg: %s %s info /var/log/syslog-files 0 100 1024000\n", LOGGING_MODULE_NAME, g_log_cmd[4].cmd);
|
||||
fprintf(stdout, " %s %s get\n", LOGGING_MODULE_NAME, g_log_cmd[4].cmd);
|
||||
|
||||
fprintf(stdout, "-----------------------------------------------------------------------------------------\n");
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ ret_code console_initial()
|
|||
memset(ttyfile_str, 0, sizeof(ttyfile_str));
|
||||
strncpy(ttyfile_str, pos, str_len);
|
||||
|
||||
/* 滤除掉段尾的回车换行 */
|
||||
/* 滤除掉段尾的回车换行 */
|
||||
if ('\n' == ttyfile_str[strlen(ttyfile_str)-1])
|
||||
{
|
||||
ttyfile_str[strlen(ttyfile_str)-1] = '\0';
|
||||
|
|
Loading…
Reference in New Issue