summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliuxueli <[email protected]>2021-08-13 19:45:18 +0800
committerliuxueli <[email protected]>2021-08-13 19:45:18 +0800
commit8de7ddb6b2f29bceb7d09fca013e6777087374bc (patch)
tree3c2ce9c70461a8f1496b6f13d9b9ce75c64ba7f8
parentf7935585b16e610e54ebb1323d27a9c4a3bbc827 (diff)
使用前置声明TLD句柄,不向外暴露rapidjson信息v5.2.2
-rw-r--r--inc/tsg_send_log.h31
-rw-r--r--src/tsg_send_log.cpp15
2 files changed, 16 insertions, 30 deletions
diff --git a/inc/tsg_send_log.h b/inc/tsg_send_log.h
index 9b2bc09..4542a1b 100644
--- a/inc/tsg_send_log.h
+++ b/inc/tsg_send_log.h
@@ -7,13 +7,6 @@
#define PRINTADDR(a, b) ((b)<RLOG_LV_FATAL ? printaddr(&(a->addr), a->threadnum) : "")
#endif
-#include "rapidjson/document.h" // rapidjson's DOM-style API
-#include "rapidjson/prettywriter.h" // for stringify JSON
-#include "rapidjson/stringbuffer.h"
-
-using namespace rapidjson;
-using namespace std;
-
typedef struct _tsg_log
{
int result_num;
@@ -33,35 +26,13 @@ typedef enum _tld_type
TLD_TYPE_MAX
}TLD_TYPE;
-struct TLD_handle_t
-{
- int thread_id;
- Document *document;
-};
-
+struct TLD_handle_t;
struct tsg_log_instance_t;
extern struct tsg_log_instance_t *g_tsg_log_instance;
struct TLD_handle_t *TLD_create(int thread_id);
-/* You can add the same key multiple times without being overwritten
- *
- * Value array(kArrayType);
- * array.PushBack(elem1, handle->document->GetAllocator());
- * array.PushBack(elem2, handle->document->GetAllocator());
- * array.PushBack(elem3, handle->document->GetAllocator());
- * TLD_append(handle, key_string, &val_array, TLD_TYPE_OBJECT);
- *
- * Value object(kObjectType);
- * object.AddMember("key1", val1, handle->document->GetAllocator());
- * object.AddMember("key2", val2, handle->document->GetAllocator());
- * object.AddMember("key3", val2, handle->document->GetAllocator());
- * TLD_append(handle, key_string, &object, TLD_TYPE_OBJECT);
- *
- * TLD_append(handle, key_string, (void *)val_long, TLD_TYPE_LONG);
- * TLD_append(handle, key_string, (void *)val_string, TLD_TYPE_STRING);
- */
int TLD_append(struct TLD_handle_t *handle, char *key, void *value, TLD_TYPE type);
int TLD_append_streaminfo(struct tsg_log_instance_t *instance, struct TLD_handle_t *handle, struct streaminfo *a_stream);
int TLD_cancel(struct TLD_handle_t *handle);
diff --git a/src/tsg_send_log.cpp b/src/tsg_send_log.cpp
index d2bff87..d9a4a35 100644
--- a/src/tsg_send_log.cpp
+++ b/src/tsg_send_log.cpp
@@ -22,9 +22,24 @@
#include "tsg_send_log.h"
#include "tsg_send_log_internal.h"
+#include "rapidjson/document.h" // rapidjson's DOM-style API
+#include "rapidjson/prettywriter.h" // for stringify JSON
+#include "rapidjson/stringbuffer.h"
+
+
+using namespace rapidjson;
+using namespace std;
+
+
char TSG_SEND_LOG_VERSION_20200729=0;
struct tsg_log_instance_t *g_tsg_log_instance;
+struct TLD_handle_t
+{
+ int thread_id;
+ Document *document;
+};
+
const id2field_t tld_type[TLD_TYPE_MAX]={{TLD_TYPE_UNKNOWN, TLD_TYPE_UNKNOWN, "UNKOWN"},
{TLD_TYPE_LONG, TLD_TYPE_LONG, "LONG"},
{TLD_TYPE_STRING, TLD_TYPE_STRING, "STRING"},