summaryrefslogtreecommitdiff
path: root/plugin/business/tsg-http/src/tsg_logger.cpp
diff options
context:
space:
mode:
authorfengweihao <[email protected]>2024-11-28 16:27:21 +0800
committerfengweihao <[email protected]>2024-11-28 16:27:21 +0800
commit15714b4ba3a23b3a294fa3a3763e41bf9bb7f276 (patch)
treecd304b496acc0c58dd3e1cc48b95eacde5acb6ef /plugin/business/tsg-http/src/tsg_logger.cpp
parent59e7f7a6a30383f75c0bf9ac5487a00dec2133b3 (diff)
Add session_uuid and log_uuid to the log fieldHEADdevelop-4.9
Diffstat (limited to 'plugin/business/tsg-http/src/tsg_logger.cpp')
-rw-r--r--plugin/business/tsg-http/src/tsg_logger.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/plugin/business/tsg-http/src/tsg_logger.cpp b/plugin/business/tsg-http/src/tsg_logger.cpp
index e7875aa..b058351 100644
--- a/plugin/business/tsg-http/src/tsg_logger.cpp
+++ b/plugin/business/tsg-http/src/tsg_logger.cpp
@@ -48,10 +48,10 @@ enum _log_action
#else
#include "uuid_v4_arm.h"
#endif
-UUIDv4::UUIDGenerator<std::mt19937_64> uuidGenerator;
-void get_http_body_uuid(char *uuid)
+void uuidv4_generate(char *uuid)
{
+ UUIDv4::UUIDGenerator<std::mt19937_64> uuidGenerator;
UUIDv4::UUID uid = uuidGenerator.getUUID();
uid.str(uuid);
return;
@@ -119,7 +119,7 @@ int tfe_get_format_host(cJSON *common_obj, const char *req_spec_host)
char *format_host=ALLOC(char, strlen(req_spec_host)+1);
sscanf(req_spec_host, "%[^:]:%u", format_host, &port);
cJSON_AddStringToObject(common_obj, "http_host", format_host);
- cJSON_AddStringToObject(common_obj, "server_fqdn", format_host);
+ cJSON_AddStringToObject(common_obj, "destination_fqdn", format_host);
FREE(&format_host);
return 0;
}
@@ -155,6 +155,21 @@ int tfe_get_string_by_cmsg(cJSON *common_obj, struct tfe_cmsg * cmsg, enum tfe_
return 0;
}
+int tfe_get_uuid_by_cmsg(cJSON *common_obj, struct tfe_cmsg * cmsg, enum tfe_cmsg_tlv_type type, const char *keyword)
+{
+ uuid_t opt_val;
+ char session_uuid[UUID_STRING_SIZE]={0};
+ uint16_t opt_out_size = 0;
+
+ int ret=tfe_cmsg_get_value(cmsg, type, (unsigned char *)opt_val, sizeof(opt_val), &opt_out_size);
+ if (ret == 0 && opt_out_size > 0)
+ {
+ uuid_unparse(opt_val,session_uuid);
+ cJSON_AddStringToObject(common_obj, keyword, session_uuid);
+ }
+ return 0;
+}
+
size_t tfe_get_c2s_byte_num(const struct tfe_stream *stream, size_t c2s_byte_num)
{
size_t rewrite_c2s_byte_num = 0;
@@ -187,7 +202,7 @@ int tfe_upload_http_body(struct proxy_logger* handle, cJSON *common_obj, struct
}
else
{
- get_http_body_uuid(uuid);
+ uuidv4_generate(uuid);
datalen=file_bucket_upload_once(handle, uuid, http_body);
if(datalen>0)
{
@@ -234,15 +249,19 @@ int proxy_send_log(struct proxy_logger* handle, const struct proxy_log* log_msg)
return 0;
}
+ char log_uuid[40] = {0};
+ uuidv4_generate(log_uuid);
+
common_obj=cJSON_CreateObject();
gettimeofday(&cur_time, NULL);
cJSON_AddNumberToObject(common_obj, "start_timestamp_ms", get_time_ms(http->start_time));
cJSON_AddNumberToObject(common_obj, "end_timestamp_ms", get_time_ms(cur_time));
+ cJSON_AddStringToObject(common_obj, "log_uuid", log_uuid);
struct tfe_cmsg *cmsg = tfe_stream_get0_cmsg(log_msg->stream);
if (cmsg != NULL)
{
- tfe_get_string_by_cmsg(common_obj, cmsg, TFE_CMSG_STREAM_TRACE_ID, "session_id");
+ tfe_get_uuid_by_cmsg(common_obj, cmsg, TFE_CMSG_STREAM_TRACE_ID, "session_uuid");
tfe_get_string_by_cmsg(common_obj, cmsg, TFE_CMSG_SRC_SUB_ID, "subscriber_id");
tfe_get_string_by_cmsg(common_obj, cmsg, TFE_CMSG_SRC_IMSI_STR, "imsi");