diff options
| author | liuxueli <[email protected]> | 2021-06-03 13:49:12 +0800 |
|---|---|---|
| committer | liuxueli <[email protected]> | 2021-06-03 13:49:12 +0800 |
| commit | 1f24c96a9544e47d7bee6f1927741cb913d965bd (patch) | |
| tree | 520c8d11ea03f0fd1fea853c64158dd4eacdad1d | |
| parent | f6534536926fed4a3d7acea67ade5b5686dd2f35 (diff) | |
common_service_category日志字段由字符串改为数组v4.2.4
| -rw-r--r-- | src/tsg_send_log.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/tsg_send_log.cpp b/src/tsg_send_log.cpp index 3fe7756..29779f6 100644 --- a/src/tsg_send_log.cpp +++ b/src/tsg_send_log.cpp @@ -286,19 +286,20 @@ static int set_duraction(struct tsg_log_instance_t *_instance, struct TLD_handle static int set_fqdn_category(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, struct streaminfo *a_stream, unsigned int *category_id, int category_id_num) { - int i=0,offset=0; - char category_str[128]={0}; - - for(i=0; i< category_id_num; i++) + int i=0; + if(category_id_num<=0 || category_id==NULL) { - offset+=snprintf(category_str+offset, sizeof(category_str)-offset, "%s%d", ((i>0) ? "," : ""), category_id[i]); + return 0; } - - if(offset>0) + + cJSON *fqdn_array=cJSON_CreateArray(); + for(i=0; i<category_id_num; i++) { - TLD_append(_handle, _instance->id2field[LOG_COMMON_FQDN_CATEGORY].name, (void *)category_str, TLD_TYPE_STRING); + cJSON_AddNumberToObject(fqdn_array, _instance->id2field[LOG_COMMON_FQDN_CATEGORY].name, category_id[i]); } + cJSON_AddItemToObject(_handle->object, _instance->id2field[LOG_COMMON_FQDN_CATEGORY].name, fqdn_array); + return 1; } |
