日志中输出线程ID,方便调试。

This commit is contained in:
zhengchao
2017-09-10 19:02:28 +08:00
parent 819d346b31
commit d276b664d0
5 changed files with 24 additions and 5 deletions

View File

@@ -9,7 +9,7 @@
#include <pthread.h> #include <pthread.h>
#include <assert.h> #include <assert.h>
const char* maat_redis_monitor="MAAT_REDIS_MONITOR"; #define maat_redis_monitor (module_name_str("MAAT_REDIS_MONITOR"))
const char* maat_redis_command="MAAT_REDIS_COMMAND"; const char* maat_redis_command="MAAT_REDIS_COMMAND";
const char* rm_key_prefix[2]={"OBSOLETE_RULE","EFFECTIVE_RULE"}; const char* rm_key_prefix[2]={"OBSOLETE_RULE","EFFECTIVE_RULE"};

View File

@@ -10,6 +10,8 @@
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
#include <sys/prctl.h> #include <sys/prctl.h>
#include <sys/syscall.h>
#include <MESA/MESA_htable.h> #include <MESA/MESA_htable.h>
#include <MESA/MESA_list_queue.h> #include <MESA/MESA_list_queue.h>
#include <MESA/MESA_handle_logger.h> #include <MESA/MESA_handle_logger.h>
@@ -28,11 +30,21 @@
#include "stream_fuzzy_hash.h" #include "stream_fuzzy_hash.h"
#include "gram_index_engine.h" #include "gram_index_engine.h"
int MAAT_FRAME_VERSION_2_0_20170831=1; int MAAT_FRAME_VERSION_2_0_20170910=1;
const char *maat_module="MAAT Frame";
const char* CHARSET_STRING[]={"NONE","gbk","big5","unicode","utf8","bin", const char* CHARSET_STRING[]={"NONE","gbk","big5","unicode","utf8","bin",
"unicode_ascii_esc","unicode_ascii_aligned","unicode_ncr_dec","unicode_ncr_hex","url_encode_gb2312","url_encode_utf8",""}; "unicode_ascii_esc","unicode_ascii_aligned","unicode_ncr_dec","unicode_ncr_hex","url_encode_gb2312","url_encode_utf8",""};
pid_t gettid()
{
return syscall(SYS_gettid);
}
const char* module_name_str(const char*name)
{
static __thread char module[64];
snprintf(module,sizeof(module),"%s(%d)", name, gettid());
return module;
}
int converHextoint(char srctmp) int converHextoint(char srctmp)
{ {
if(isdigit(srctmp)) if(isdigit(srctmp))

View File

@@ -463,6 +463,9 @@ void redis_monitor_traverse(unsigned int version,redisContext *c,
void* u_para, void* u_para,
const unsigned char* dec_key, const unsigned char* dec_key,
_Maat_feather_t* feather); _Maat_feather_t* feather);
const char* module_name_str(const char*name);
#define maat_module (module_name_str("MAAT_Frame"))
#endif #endif

View File

@@ -1,11 +1,14 @@
#include "MESA_handle_logger.h" #include "MESA_handle_logger.h"
#include "config_monitor.h" #include "config_monitor.h"
#include "Maat_rule_internal.h"
#include <dirent.h> #include <dirent.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <openssl/evp.h> #include <openssl/evp.h>
const char* module_config_monitor="CONFIG_MONITOR";
#define module_config_monitor (module_name_str("CONFIG_MONITOR"))
#define CM_UPDATE_TYPE_ERR -1 #define CM_UPDATE_TYPE_ERR -1
#define CM_UPDATE_TYPE_NONE 0 #define CM_UPDATE_TYPE_NONE 0

View File

@@ -12,7 +12,8 @@
#include "cJSON.h" #include "cJSON.h"
#include "map_str2int.h" #include "map_str2int.h"
#include "Maat_rule_internal.h" #include "Maat_rule_internal.h"
const char* maat_json="MAAT JSON"; #define maat_json (module_name_str("MAAT_JSON"))
const char* untitled_group_name="Untitled"; const char* untitled_group_name="Untitled";
const int json_version=1; const int json_version=1;
#define MAX_PATH_LINE 256 #define MAX_PATH_LINE 256