使用前置声明TLD句柄,不向外暴露rapidjson信息

This commit is contained in:
liuxueli
2021-08-13 19:45:18 +08:00
parent f7935585b1
commit 8de7ddb6b2
2 changed files with 16 additions and 30 deletions

View File

@@ -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);

View File

@@ -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"},