diff --git a/srcs/httpserver/src/haywire/configuration/configuration.c b/srcs/httpserver/src/haywire/configuration/configuration.c index f7fab52..bec3bb0 100644 --- a/srcs/httpserver/src/haywire/configuration/configuration.c +++ b/srcs/httpserver/src/haywire/configuration/configuration.c @@ -23,7 +23,7 @@ int configuration_handler(void *user, const char *section, const char *name, con configuration *load_configuration(const char *filename) { configuration *config = malloc(sizeof(configuration)); if (ini_parse(filename, configuration_handler, config) < 0) { - LOG_MSG(error, ZLOG_MOD_HTTPD, "Can't load configuration\n"); + LOG_MOD(error, ZLOG_MOD_HTTPD, "Can't load configuration\n"); return NULL; } return config; diff --git a/srcs/httpserver/src/haywire/http_server.c b/srcs/httpserver/src/haywire/http_server.c index f86bdb9..d87f4d8 100644 --- a/srcs/httpserver/src/haywire/http_server.c +++ b/srcs/httpserver/src/haywire/http_server.c @@ -21,7 +21,7 @@ #include "misc.h" #include "zlog_module.h" -#define UVERR(err, msg) LOG_MSG(error, ZLOG_MOD_HTTPD, "%s: %s\n", msg, uv_strerror(err)) +#define UVERR(err, msg) LOG_MOD(error, ZLOG_MOD_HTTPD, "%s: %s\n", msg, uv_strerror(err)) //fprintf(stderr, "%s: %s\n", msg, uv_strerror(err)) #if 0 #define CHECK(r, msg) \ @@ -88,7 +88,7 @@ int hw_init_from_config(char *configuration_filename) { void print_configuration() { #if 0 - LOG_MSG(debug, ZLOG_MOD_HTTPD, "Address: %s\n\tPort: %d\n\tThreads: %d\n\tBalancer: %s\n\t" + LOG_MOD(debug, ZLOG_MOD_HTTPD, "Address: %s\n\tPort: %d\n\tThreads: %d\n\tBalancer: %s\n\t" "Parser: %s\n\tTCP No Delay: %s\n\tListen backlog: %d\n\tMaximum request size: %d\n", config->http_listen_address, config->http_listen_port, @@ -134,7 +134,7 @@ void hw_http_add_route(char *route, http_request_callback callback, void *user_d routes = kh_init(string_hashmap); } set_route(routes, route, route_entry); - // LOG_MSG(debug, ZLOG_MOD_HTTPD, "Added route path: [%s]\n", route); // TODO: Replace with logging instead. + // LOG_MOD(debug, ZLOG_MOD_HTTPD, "Added route path: [%s]\n", route); // TODO: Replace with logging instead. } void free_http_server() { @@ -149,7 +149,7 @@ void free_http_server() { kh_destroy(string_hashmap, routes); uv_close((uv_handle_t *)&server, NULL); uninit_http_request_cache(); - LOG_MSG(info, + LOG_MOD(info, ZLOG_MOD_HTTPD, "HTTP Server Close http://%s:%d\n", config->http_listen_address, @@ -197,7 +197,7 @@ int hw_http_open() { int rc; rc = uv_tcp_init_ex(uv_loop, &server, AF_INET); if (rc != 0) { - LOG_MSG(warn, ZLOG_MOD_HTTPD, "TWO %d\n", rc); + LOG_MOD(warn, ZLOG_MOD_HTTPD, "TWO %d\n", rc); } if (strcmp(config->balancer, "reuseport") == 0) { @@ -205,11 +205,11 @@ int hw_http_open() { int on = 1; rc = uv_fileno(&server, &fd); if (rc != 0) { - LOG_MSG(warn, ZLOG_MOD_HTTPD, "ONE %d\n", rc); + LOG_MOD(warn, ZLOG_MOD_HTTPD, "ONE %d\n", rc); } rc = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (char *)&on, sizeof(on)); if (rc != 0) { - LOG_MSG(warn, ZLOG_MOD_HTTPD, "THREE %d\n", errno); + LOG_MOD(warn, ZLOG_MOD_HTTPD, "THREE %d\n", errno); } } @@ -225,7 +225,7 @@ int hw_http_open() { uv_listen((uv_stream_t *)&server, (int)config->listen_backlog, http_stream_on_connect); print_configuration(); - LOG_MSG(info, + LOG_MOD(info, ZLOG_MOD_HTTPD, "HTTP Server Listening at http://%s:%d\n", config->http_listen_address, @@ -269,7 +269,7 @@ int hw_http_open() { } print_configuration(); - LOG_MSG(debug, ZLOG_MOD_HTTPD, "Listening...\n"); + LOG_MOD(debug, ZLOG_MOD_HTTPD, "Listening...\n"); //uv_run(uv_loop, UV_RUN_DEFAULT); } @@ -299,7 +299,7 @@ void reuseport_thread_start(void *arg) { uv_fileno(&server, &fd); rc = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (char *)&on, sizeof(on)); if (rc != 0) { - LOG_MSG(warn, ZLOG_MOD_HTTPD, "%d\n", errno); + LOG_MOD(warn, ZLOG_MOD_HTTPD, "%d\n", errno); } uv_tcp_bind(&server, (const struct sockaddr *)&addr, 0); diff --git a/srcs/libs/banner/banner.c b/srcs/libs/banner/banner.c index 75a4b87..1942b9d 100644 --- a/srcs/libs/banner/banner.c +++ b/srcs/libs/banner/banner.c @@ -29,13 +29,13 @@ void banner_show() { fclose(fp); - LOG_MSG(info, + LOG_MOD(info, ZLOG_MOD_MAIN, "================== Banner Used ===================\n%s\n", utstring_body(pBannerText)); utstring_free(pBannerText); } else { - LOG_MSG(error, ZLOG_MOD_MAIN, "Banner file does not exists: %s\n", utstring_body(pPath)); + LOG_MOD(error, ZLOG_MOD_MAIN, "Banner file does not exists: %s\n", utstring_body(pPath)); } utstring_free(pPath); diff --git a/srcs/libs/configure/config.c b/srcs/libs/configure/config.c index 368b243..6fc1a6f 100644 --- a/srcs/libs/configure/config.c +++ b/srcs/libs/configure/config.c @@ -137,7 +137,7 @@ static int cfg_is_upgrade(PCONFIG_ITEM pItem) { static const char *load_string_value(const char *pKeyName) { const char *pCfgVal; if (config_lookup_string(&g_cfgContent, pKeyName, &pCfgVal) != CONFIG_TRUE) { - LOG_MSG(error, ZLOG_MOD_CONFIG, "No {%s} setting in configuration file.\n", pKeyName); + LOG_MOD(error, ZLOG_MOD_CONFIG, "No {%s} setting in configuration file.\n", pKeyName); return NULL; } @@ -151,7 +151,7 @@ static const char *load_string_value(const char *pKeyName) { unsigned char *pBuf = base64_decode(&pCfgVal[strlen(ENC_HEAD)], (unsigned int *)&bufSize); if (pBuf == NULL || bufSize <= 0) { - LOG_MSG(error, + LOG_MOD(error, ZLOG_MOD_CONFIG, "{%s} setting [%s] maybe a encryption message, base64 decode error.\n", pKeyName, @@ -180,7 +180,7 @@ static const char *load_string_value(const char *pKeyName) { static int load_boolean_value(const char *pKeyName) { int val; if (config_lookup_bool(&g_cfgContent, pKeyName, &val) != CONFIG_TRUE) { - LOG_MSG(error, ZLOG_MOD_CONFIG, "No {%s} setting in configuration file.\n", pKeyName); + LOG_MOD(error, ZLOG_MOD_CONFIG, "No {%s} setting in configuration file.\n", pKeyName); return DEFAULT_INTEGRAL_ERR_VALUE; } @@ -190,7 +190,7 @@ static int load_boolean_value(const char *pKeyName) { static long long int load_integral_value(const char *pKeyName) { long long val; if (config_lookup_int64(&g_cfgContent, pKeyName, &val) != CONFIG_TRUE) { - LOG_MSG(error, ZLOG_MOD_CONFIG, "No {%s} setting in configuration file.\n", pKeyName); + LOG_MOD(error, ZLOG_MOD_CONFIG, "No {%s} setting in configuration file.\n", pKeyName); return DEFAULT_INTEGRAL_ERR_VALUE; } @@ -200,7 +200,7 @@ static long long int load_integral_value(const char *pKeyName) { static double load_float_value(const char *pKeyName) { double val; if (config_lookup_float(&g_cfgContent, pKeyName, &val) != CONFIG_TRUE) { - LOG_MSG(error, ZLOG_MOD_CONFIG, "No {%s} setting in configuration file.\n", pKeyName); + LOG_MOD(error, ZLOG_MOD_CONFIG, "No {%s} setting in configuration file.\n", pKeyName); return DEFAULT_INTEGRAL_ERR_VALUE; } @@ -396,7 +396,7 @@ static void refreshCfgFileCb() { int cfgUpgrade = FALSE; if (!config_read_file(&g_cfgContent, g_cfgFilePath)) { - LOG_MSG(error, + LOG_MOD(error, ZLOG_MOD_CONFIG, "%s:%d - %s\n", config_error_file(&g_cfgContent), @@ -616,37 +616,37 @@ const char *config_item_dump_fmt(const char *titleMessage) { void config_item_dump(const char *titleMessage) { const char *pMsg = config_item_dump_fmt(titleMessage); - LOG_MSG(info, ZLOG_MOD_CONFIG, "%s", pMsg); + LOG_MOD(info, ZLOG_MOD_CONFIG, "%s", pMsg); free((char *)pMsg); #if 0 PCONFIG_ITEM pItem, pTmp; //int i, k = ARRAY_SIZE(g_sysConfigMap); - LOG_MSG(info, ZLOG_MOD_CONFIG, "================== %s ===================\n", titleMessage == NULL ? "" : titleMessage); + LOG_MOD(info, ZLOG_MOD_CONFIG, "================== %s ===================\n", titleMessage == NULL ? "" : titleMessage); HASH_ITER(hh, g_pConfigItem, pItem, pTmp) { switch (pItem->valType) { case VAL_BOOL: - LOG_MSG(info, ZLOG_MOD_CONFIG, "%s%-25s: [%-45s] = %s\n", + LOG_MOD(info, ZLOG_MOD_CONFIG, "%s%-25s: [%-45s] = %s\n", cfg_is_upgrade(pItem) ? "*" : " ", pItem->pStrId, pItem->pcfgKey, CFG_BOOL_VALUE(pItem) ? "True" : "False"); break; case VAL_INT: - LOG_MSG(info, ZLOG_MOD_CONFIG, "%s%-25s: [%-45s] = %lld\n", + LOG_MOD(info, ZLOG_MOD_CONFIG, "%s%-25s: [%-45s] = %lld\n", cfg_is_upgrade(pItem) ? "*" : " ", pItem->pStrId, pItem->pcfgKey, CFG_INT_VALUE(pItem)); break; case VAL_FLOAT: - LOG_MSG(info, ZLOG_MOD_CONFIG, "%s%-25s: [%-45s] = %Lf\n", + LOG_MOD(info, ZLOG_MOD_CONFIG, "%s%-25s: [%-45s] = %Lf\n", cfg_is_upgrade(pItem) ? "*" : " ", pItem->pStrId, pItem->pcfgKey, CFG_FLOAT_VALUE(pItem)); break; case VAL_STR: - LOG_MSG(info, ZLOG_MOD_CONFIG, "%s%-25s: [%-45s] = \"%s\"\n", + LOG_MOD(info, ZLOG_MOD_CONFIG, "%s%-25s: [%-45s] = \"%s\"\n", cfg_is_upgrade(pItem) ? "*" : " ", pItem->pStrId, pItem->pcfgKey, @@ -713,7 +713,7 @@ int init_config_system(const char *pCfgFile, const char *pKey) { int i; if (!file_exists(pCfgFile)) { - LOG_MSG(error, ZLOG_MOD_CONFIG, "Configuration file [%s] not exists\n", pCfgFile); + LOG_MOD(error, ZLOG_MOD_CONFIG, "Configuration file [%s] not exists\n", pCfgFile); return -ERR_FILE_NOT_EXISTS; } @@ -775,7 +775,7 @@ const char *get_config_key(const char *pKeygen) { unsigned char *pBase64 = (unsigned char *)base64_decode(pKeygen, (unsigned int *)&outSize); if (pBase64 == NULL) { - LOG_MSG(error, ZLOG_MOD_CONFIG, "Base64 decode error: %s\n", pKeygen); + LOG_MOD(error, ZLOG_MOD_CONFIG, "Base64 decode error: %s\n", pKeygen); return NULL; } diff --git a/srcs/libs/crypto/base64.c b/srcs/libs/crypto/base64.c index 9ea293d..17369a4 100644 --- a/srcs/libs/crypto/base64.c +++ b/srcs/libs/crypto/base64.c @@ -129,7 +129,7 @@ unsigned char *base64_decode(const char *pBase64, unsigned int *pOutSize) { #else EVP_DecodeInit(pCtx); if (EVP_DecodeUpdate(pCtx, pDecode, &enSize, (const unsigned char *)pBase64, size) == -1) { - LOG_MSG(error, ZLOG_MOD_CRYPTO, "Decode [%s] error\n", pBase64); + LOG_MOD(error, ZLOG_MOD_CRYPTO, "Decode [%s] error\n", pBase64); free(pDecode); return NULL; } @@ -142,7 +142,7 @@ unsigned char *base64_decode(const char *pBase64, unsigned int *pOutSize) { EVP_DecodeFinal(&ctx, pDecode + enSize, &size); #else if (EVP_DecodeFinal(pCtx, pDecode, &enSize) == -1) { - LOG_MSG(error, ZLOG_MOD_CRYPTO, "Finish decode [%s] error\n", pBase64); + LOG_MOD(error, ZLOG_MOD_CRYPTO, "Finish decode [%s] error\n", pBase64); free(pDecode); return NULL; } diff --git a/srcs/libs/crypto/hash_digest.c b/srcs/libs/crypto/hash_digest.c index 8764681..86f1dc3 100644 --- a/srcs/libs/crypto/hash_digest.c +++ b/srcs/libs/crypto/hash_digest.c @@ -57,7 +57,7 @@ int hash_digest_file(HASH_TYPE hashType, const char *pFileName, char **pHashValu fd = open(pFileName, O_RDONLY); if (fd == -1) { - LOG_MSG(error, ZLOG_MOD_CRYPTO, "Open File %s error\n", pFileName); + LOG_MOD(error, ZLOG_MOD_CRYPTO, "Open File %s error\n", pFileName); EVP_MD_CTX_destroy(pCtx); return (-ERR_OPEN_FILE); } diff --git a/srcs/libs/include/misc.h b/srcs/libs/include/misc.h index 751e8bc..de22005 100644 --- a/srcs/libs/include/misc.h +++ b/srcs/libs/include/misc.h @@ -42,7 +42,7 @@ extern "C" { #define MAX_IP_V4_STR (16) #define MAX_MAC_ADDR_STR (18) -#define DEBUG_CODE_LINE() (dzlog_debug("\n")) +#define DEBUG_CODE_LINE() LOG_MSG(debug, "\n") const char *get_cur_process_dir(); const char *get_cur_process_name(); diff --git a/srcs/libs/include/zlog_module.h b/srcs/libs/include/zlog_module.h index 651ab99..118f974 100644 --- a/srcs/libs/include/zlog_module.h +++ b/srcs/libs/include/zlog_module.h @@ -32,7 +32,12 @@ typedef enum { ZLOG_MOD_MAX, } ZLOG_MOD_NAME; -#define LOG_MSG(level, mod, format, ...) \ +#define LOG_MSG(level, format, ...) \ + do { \ + zlog_##level(zlog_get_mod_cat(ZLOG_MOD_MAIN), format, ##__VA_ARGS__); \ + } while (0) + +#define LOG_MOD(level, mod, format, ...) \ do { \ zlog_category_t *cat; \ if ((cat = zlog_get_mod_cat((mod))) == NULL) { \ @@ -43,7 +48,7 @@ typedef enum { } \ } while (0) -#define LOG_MSG_HEX(level, mod, format, ...) \ +#define LOG_MOD_HEX(level, mod, format, ...) \ do { \ zlog_category_t *cat; \ if ((cat = zlog_get_mod_cat((mod))) == NULL) { \ diff --git a/srcs/libs/init/init_runtime.c b/srcs/libs/init/init_runtime.c index d1be32a..f2421f0 100644 --- a/srcs/libs/init/init_runtime.c +++ b/srcs/libs/init/init_runtime.c @@ -30,7 +30,7 @@ static int g_isInited = FALSE; static void catch_system_interupt(int UNUSED(sig_num)) { if (g_pid == uv_os_getpid()) { printf("\n"); - LOG_MSG(warn, ZLOG_MOD_INIT, "System close, clearing system resources..........\n\n"); + LOG_MOD(warn, ZLOG_MOD_INIT, "System close, clearing system resources..........\n\n"); task_manager_exit(); sleep(1); } @@ -77,30 +77,30 @@ int user_init(const char *pAppCfgFile, const char *pCfgDirectory, const char *pK utstring_printf(pPath, "%s/%s", bufCfgDir, "zlog.conf"); if (file_exists(utstring_body(pPath))) { - if ((ret = dzlog_init(utstring_body(pPath), get_cur_process_name())) != ERR_SUCCESS) { + if ((ret = zlog_init(utstring_body(pPath))) != ERR_SUCCESS) { printf("Zlog configure file [%s] init result: %d+++++\n", utstring_body(pPath), ret); zlog_profile(); return -ERR_ZLOG_INIT; } else { - LOG_MSG(info, ZLOG_MOD_INIT, "Zlog used configure file [%s]\n", utstring_body(pPath)); + LOG_MOD(info, ZLOG_MOD_INIT, "Zlog used configure file [%s]\n", utstring_body(pPath)); + dzlog_init(utstring_body(pPath), get_cur_process_name()); + // zlog_level_switch(zlog_get_category(get_cur_process_name()), + // logLevel > ZLOG_LEVEL_DEBUG ? logLevel : ZLOG_LEVEL_DEBUG); } } else { printf("Zlog configure file [%s] not found, Zlog system not work+++++\n", utstring_body(pPath)); } - zlog_level_switch(zlog_get_category(get_cur_process_name()), - logLevel > ZLOG_LEVEL_DEBUG ? logLevel : ZLOG_LEVEL_DEBUG); - utstring_free(pPath); // 处置化配置文件库,系统集成配置文件支持功能 - LOG_MSG(info, ZLOG_MOD_INIT, "System used configure file [%s]\n", bufCfgFile); + LOG_MOD(info, ZLOG_MOD_INIT, "System used configure file [%s]\n", bufCfgFile); if ((ret = init_config_system(bufCfgFile, pKey)) != ERR_SUCCESS) { - LOG_MSG(error, ZLOG_MOD_INIT, "Load system configuration error: %d\n", ret); + LOG_MOD(error, ZLOG_MOD_INIT, "Load system configuration error: %d\n", ret); return -ERR_CONFIG_INIT; } - LOG_MSG(info, + LOG_MOD(info, ZLOG_MOD_INIT, "%s library version %s information: %s (Build: %s %s GCC Ver:%s) With %lu(bits) OS\n", VCPE_LIB_NAME, @@ -123,11 +123,11 @@ int user_init(const char *pAppCfgFile, const char *pCfgDirectory, const char *pK } if ((ret = mq_init()) != ERR_SUCCESS) { - LOG_MSG(error, ZLOG_MOD_INIT, "Message queue init error: %d\n", ret); + LOG_MOD(error, ZLOG_MOD_INIT, "Message queue init error: %d\n", ret); } if ((ret = mq_data_init()) != ERR_SUCCESS) { - LOG_MSG(error, ZLOG_MOD_INIT, "Message queue init error: %d\n", ret); + LOG_MOD(error, ZLOG_MOD_INIT, "Message queue init error: %d\n", ret); } http_svr_init(); diff --git a/srcs/libs/misc/misc.c b/srcs/libs/misc/misc.c index fbae2d7..6fb703d 100644 --- a/srcs/libs/misc/misc.c +++ b/srcs/libs/misc/misc.c @@ -53,14 +53,14 @@ int copy_file(const char *pSrc, const char *pDest) { ssize_t sz; if (stat(pSrc, &st) != 0) { - LOG_MSG(error, ZLOG_MOD_MISC, "Get File %s Size Error\n", pSrc); + LOG_MOD(error, ZLOG_MOD_MISC, "Get File %s Size Error\n", pSrc); return (-ERR_GET_FILE_SIZE); } fdSrc = open(pSrc, O_RDONLY); if (fdSrc < 0) { - LOG_MSG(error, ZLOG_MOD_MISC, "Open File %s Error\n", pSrc); + LOG_MOD(error, ZLOG_MOD_MISC, "Open File %s Error\n", pSrc); return (-ERR_OPEN_FILE); } @@ -68,14 +68,14 @@ int copy_file(const char *pSrc, const char *pDest) { if (fdDest < 0) { close(fdSrc); - LOG_MSG(error, ZLOG_MOD_MISC, "Open File %s Error\n", pDest); + LOG_MOD(error, ZLOG_MOD_MISC, "Open File %s Error\n", pDest); return (-ERR_OPEN_FILE); } sz = sendfile(fdDest, fdSrc, NULL, st.st_size); if (sz != st.st_size) { - LOG_MSG(error, ZLOG_MOD_MISC, "Copy File Size Error: %zd, %ld\n", sz, st.st_size); + LOG_MOD(error, ZLOG_MOD_MISC, "Copy File Size Error: %zd, %ld\n", sz, st.st_size); close(fdSrc); close(fdDest); return (-ERR_COPY_FILE); @@ -201,7 +201,7 @@ int get_nic_info(const char *pName, sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (sock < 0) { - LOG_MSG(error, ZLOG_MOD_MISC, "Get local NIC information failed\n"); + LOG_MOD(error, ZLOG_MOD_MISC, "Get local NIC information failed\n"); return -ERR_SYS_INIT; } diff --git a/srcs/libs/misc/zvector.c b/srcs/libs/misc/zvector.c index 7b59aa2..9cc7e5b 100644 --- a/srcs/libs/misc/zvector.c +++ b/srcs/libs/misc/zvector.c @@ -74,17 +74,17 @@ // Declare Vector status flags: enum { - ZVS_NONE = 0, // - Set or Reset vector's status + ZVS_NONE = 0, // - Set or Reset vector's status // register. ZVS_CUST_WIPE_ON = 1 << 0, // - Set the bit to indicate a custom // secure wipe // function has been set. - ZVS_USR1_FLAG = 1 << 1, // - This is a "user" available flag, + ZVS_USR1_FLAG = 1 << 1, // - This is a "user" available flag, // a user code can set it to 1 or // 0 for its own need. // Can be useful when signaling // between threads. - ZVS_USR2_FLAG = 1 << 2 + ZVS_USR2_FLAG = 1 << 2 }; #ifndef ZVECT_MEMX_METHOD @@ -124,18 +124,18 @@ struct ZVECT_PACKING p_vector { zvect_index end; // - Current Array size. size - 1 gives // us the pointer to the last element // in the vector. - uint32_t flags; // - This flag set is used to store all + uint32_t flags; // - This flag set is used to store all // Vector's properties. // It contains bits that set Secure // Wipe, Auto Shrink, Pass Items By // Ref etc. - size_t data_size; // - User DataType size. - // This should be 2 bytes size on a - // 16-bit system, 4 bytes on a 32 - // bit, 8 bytes on a 64 bit. But - // check your compiler for the - // actual size, it's implementation - // dependent. + size_t data_size; // - User DataType size. + // This should be 2 bytes size on a + // 16-bit system, 4 bytes on a 32 + // bit, 8 bytes on a 64 bit. But + // check your compiler for the + // actual size, it's implementation + // dependent. #if (ZVECT_THREAD_SAFE == 1) #if MUTEX_TYPE == 0 void *lock ZVECT_DATAALIGN; // - Vector's mutex for thread safe @@ -143,7 +143,7 @@ struct ZVECT_PACKING p_vector { // This should be 2 bytes size on a // 16 bit machine, 4 bytes on a 32 // bit 4 bytes on a 64 bit. - void *cond; // - Vector's mutex condition variable + void *cond; // - Vector's mutex condition variable #elif MUTEX_TYPE == 1 pthread_mutex_t lock ZVECT_DATAALIGN; // - Vector's mutex for thread safe @@ -158,7 +158,7 @@ struct ZVECT_PACKING p_vector { // micro-transactions or user locks. // Check your WINNT.H to calculate // the size of this one. - CONDITION_VARIABLE cond; // - Vector's mutex condition variable + CONDITION_VARIABLE cond; // - Vector's mutex condition variable #endif // MUTEX_TYPE #endif // ZVECT_THREAD_SAFE void **data ZVECT_DATAALIGN; // - Vector's storage. @@ -202,8 +202,8 @@ static uint32_t p_init_state = 0; // Errors and messages handling: enum ZVECT_LOGPRIORITY { - ZVLP_NONE = 0, // No priority - ZVLP_INFO = 1 << 0, // This is an informational priority + ZVLP_NONE = 0, // No priority + ZVLP_INFO = 1 << 0, // This is an informational priority // message. ZVLP_LOW = 1 << 1, // " low " ZVLP_MEDIUM = 1 << 2, // " medium " @@ -220,7 +220,7 @@ unsigned int LOG_PRIORITY = (ZVLP_ERROR | ZVLP_HIGH | ZVLP_MEDIUM); #endif // This is a vprintf wrapper nothing special: -static void log_msg(int const priority, const char *const format, ...) { +static void LOG_MOD(int const priority, const char *const format, ...) { va_list args; va_start(args, format); @@ -262,7 +262,7 @@ static void *safe_strncpy(const char *const str_src, size_t max_len) { str_dst = (void *)malloc(sizeof(char *) * (sizeof(tmp_dst) + 1)); if (str_dst == NULL) { - log_msg(ZVLP_ERROR, "Error: %*i, %s\n", 8, -1000, "Out of memory!"); + LOG_MOD(ZVLP_ERROR, "Error: %*i, %s\n", 8, -1000, "Out of memory!"); } else { strncpy((char *)str_dst, tmp_dst, sizeof(char) * max_len); } @@ -324,7 +324,7 @@ p_throw_error(const zvect_retval error_code, const char *error_message) { message = (char *)safe_strncpy(error_message, msg_len); } - log_msg(ZVLP_ERROR, "Error: %*i, %s\n", 8, error_code, message); + LOG_MOD(ZVLP_ERROR, "Error: %*i, %s\n", 8, error_code, message); if (locally_allocated) { free((void *)message); } @@ -374,9 +374,9 @@ static inline ZVECT_ALWAYSINLINE static inline void *p_vect_memmove(const void *__restrict dst, const void *__restrict src, size_t size) { #ifdef DEBUG - log_msg(ZVLP_INFO, "p_vect_memmove: dst %*p\n", 14, dst); - log_msg(ZVLP_INFO, "p_vect_memmove: src %*p\n", 14, src); - log_msg(ZVLP_INFO, "p_vect_memmove: size %*u\n", 14, size); + LOG_MOD(ZVLP_INFO, "p_vect_memmove: dst %*p\n", 14, dst); + LOG_MOD(ZVLP_INFO, "p_vect_memmove: src %*p\n", 14, src); + LOG_MOD(ZVLP_INFO, "p_vect_memmove: size %*u\n", 14, size); #endif return memmove((void *)dst, src, size); } @@ -685,7 +685,9 @@ static void p_free_items(c_vector const v, zvect_index first, zvect_index offset /* * Set vector capacity to a specific new_capacity value */ -static zvect_retval p_vect_set_capacity(c_vector const v, const zvect_index direction, const zvect_index new_capacity_) { +static zvect_retval p_vect_set_capacity(c_vector const v, + const zvect_index direction, + const zvect_index new_capacity_) { zvect_index new_capacity = new_capacity_; if (new_capacity <= v->init_capacity) { @@ -1235,7 +1237,7 @@ static inline zvect_retval p_vect_remove_at(c_vector const v, const zvect_index } // This is the inline implementation for all the "delete" methods -static inline zvect_retval p_vect_delete_at(c_vector const v, +static inline zvect_retval p_vect_delete_at(c_vector const v, const zvect_index start, const zvect_index offset, uint32_t flags) { @@ -1258,13 +1260,13 @@ static inline zvect_retval p_vect_delete_at(c_vector const v, zvect_index tot_items = start + offset; #ifdef DEBUG /* - log_msg(ZVLP_INFO, "p_vect_delete_at: start %*u\n", 14, start); - log_msg(ZVLP_INFO, "p_vect_delete_at: offset %*u\n", 14, offset); - log_msg(ZVLP_INFO, "p_vect_delete_at: tot_items %*u\n", 14, tot_items); - log_msg(ZVLP_INFO, "p_vect_delete_at: v->begin %*u\n", 14, v->begin); - log_msg(ZVLP_INFO, "p_vect_delete_at: v->end %*u\n", 14, v->end); - log_msg(ZVLP_INFO, "p_vect_delete_at: vsize %*u\n", 14, vsize); - log_msg(ZVLP_INFO, "p_vect_delete_at: data %*p\n", 14, v->data); + LOG_MOD(ZVLP_INFO, "p_vect_delete_at: start %*u\n", 14, start); + LOG_MOD(ZVLP_INFO, "p_vect_delete_at: offset %*u\n", 14, offset); + LOG_MOD(ZVLP_INFO, "p_vect_delete_at: tot_items %*u\n", 14, tot_items); + LOG_MOD(ZVLP_INFO, "p_vect_delete_at: v->begin %*u\n", 14, v->begin); + LOG_MOD(ZVLP_INFO, "p_vect_delete_at: v->end %*u\n", 14, v->end); + LOG_MOD(ZVLP_INFO, "p_vect_delete_at: vsize %*u\n", 14, vsize); + LOG_MOD(ZVLP_INFO, "p_vect_delete_at: data %*p\n", 14, v->data); */ #endif if ((vsize > 1) && (start < (vsize - 1)) && (tot_items < vsize) && (v->data != NULL)) { @@ -1272,7 +1274,7 @@ static inline zvect_retval p_vect_delete_at(c_vector const v, #ifdef DEBUG /* for (zvect_index ptrID = start; ptrID < start + offset; ptrID++) { - log_msg(ZVLP_INFO, "p_vect_delete_at: data ptr %*p\n", 14, v->data + (v->begin + ptrID)); + LOG_MOD(ZVLP_INFO, "p_vect_delete_at: data ptr %*p\n", 14, v->data + (v->begin + ptrID)); }*/ #endif // Safe erase items? @@ -1596,7 +1598,7 @@ void vect_set_wipefunct(const c_vector v, void (*f1)(const void *, size_t)) { // Set custom Safe Wipe function: v->SfWpFunc = f1; // p_vect_memcpy(v->SfWpFunc, f1, sizeof(void *)); - v->status |= ZVS_CUST_WIPE_ON; + v->status |= ZVS_CUST_WIPE_ON; } // Add an item at the END (top) of the vector @@ -2322,8 +2324,8 @@ static void p_vect_qsort(vector v, zvect_index low, zvect_index high, int (*comp // to deal with arrays of pointers together with having a custom // compare function: static void p_vect_qsort(const c_vector v, - zvect_index l, - zvect_index r, + zvect_index l, + zvect_index r, int (*compare_func)(const void *, const void *)) { if (r <= l) { return; @@ -2460,8 +2462,8 @@ static bool p_standard_binary_search(vector v, // function that makes it suitable also to search through strings // and other types of vectors. static bool p_adaptive_binary_search(c_vector const v, - const void *key, - zvect_index *item_index, + const void *key, + zvect_index *item_index, int (*f1)(const void *, const void *)) { zvect_index bot; zvect_index top; @@ -2544,7 +2546,7 @@ bool vect_bsearch(c_vector const v, const void *key, int (*f1)(const void *, con return false; } - *item_index = 0; + *item_index = 0; // check if the vector exists: zvect_retval rval = p_vect_check(v); if (rval) { @@ -2844,8 +2846,11 @@ JOB_DONE: * position s1). * */ -void vect_insert(c_vector const v1, - c_vector const v2, const zvect_index s2, const zvect_index e2, const zvect_index s1) { +void vect_insert(c_vector const v1, + c_vector const v2, + const zvect_index s2, + const zvect_index e2, + const zvect_index s1) { // check if the vectors v1 and v2 exist: zvect_retval rval = p_vect_check(v1) | p_vect_check(v2); if (rval) { @@ -2948,7 +2953,7 @@ static inline zvect_retval p_vect_move(c_vector const v1, c_vector v2, const zve zvect_retval rval = 0; #ifdef DEBUG - log_msg(ZVLP_INFO, "p_vect_move: move pointers set from v2 to v1\n"); + LOG_MOD(ZVLP_INFO, "p_vect_move: move pointers set from v2 to v1\n"); #endif // We can only copy vectors with the same data_size! if (v1->data_size != v2->data_size) { @@ -2972,7 +2977,7 @@ static inline zvect_retval p_vect_move(c_vector const v1, c_vector v2, const zve } #ifdef DEBUG - log_msg(ZVLP_INFO, + LOG_MOD(ZVLP_INFO, "p_vect_move: v2 capacity = %*u, begin = %*u, end = %*u, size = %*u, s2 = %*u, ee2 = %*u\n", 10, p_vect_capacity(v2), @@ -2987,7 +2992,7 @@ static inline zvect_retval p_vect_move(c_vector const v1, c_vector v2, const zve 10, ee2); - log_msg(ZVLP_INFO, + LOG_MOD(ZVLP_INFO, "p_vect_move: v1 capacity = %*u, begin = %*u, end = %*u, size = %*u\n", 10, p_vect_capacity(v1), @@ -3005,7 +3010,7 @@ static inline zvect_retval p_vect_move(c_vector const v1, c_vector v2, const zve } #ifdef DEBUG - log_msg(ZVLP_INFO, + LOG_MOD(ZVLP_INFO, "p_vect_move: v1 capacity = %*u, begin = %*u, end = %*u, size = %*u\n", 10, p_vect_capacity(v1), @@ -3016,7 +3021,7 @@ static inline zvect_retval p_vect_move(c_vector const v1, c_vector v2, const zve 10, p_vect_size(v1)); - log_msg(ZVLP_INFO, "p_vect_move: ready to copy pointers set\n"); + LOG_MOD(ZVLP_INFO, "p_vect_move: ready to copy pointers set\n"); #endif // Move v2 (from s2) in v1 at the end of v1: const void *rptr = NULL; @@ -3039,7 +3044,7 @@ static inline zvect_retval p_vect_move(c_vector const v1, c_vector v2, const zve v1->end += ee2; #ifdef DEBUG - log_msg(ZVLP_INFO, "p_vect_move: done copy pointers set\n"); + LOG_MOD(ZVLP_INFO, "p_vect_move: done copy pointers set\n"); #endif // Clean up v2 memory slots that no longer belong to v2: @@ -3047,7 +3052,7 @@ static inline zvect_retval p_vect_move(c_vector const v1, c_vector v2, const zve DONE_PROCESSING: #ifdef DEBUG - log_msg(ZVLP_INFO, + LOG_MOD(ZVLP_INFO, "p_vect_move: v1 capacity = %*u, begin = %*u, end = %*u, size = %*u\n", 10, p_vect_capacity(v1), @@ -3057,7 +3062,7 @@ DONE_PROCESSING: v1->end, 10, p_vect_size(v1)); - log_msg(ZVLP_INFO, + LOG_MOD(ZVLP_INFO, "p_vect_move: v2 capacity = %*u, begin = %*u, end = %*u, size = %*u\n", 10, p_vect_capacity(v2), @@ -3071,6 +3076,7 @@ DONE_PROCESSING: return rval; } + // END of p_vect_move ////////////////////////////////////////////////////////////////// @@ -3089,10 +3095,10 @@ void vect_move(c_vector const v1, c_vector v2, const zvect_index s2, const zvect zvect_retval lock_owner1 = (locking_disabled || (v1->flags & ZV_NOLOCKING)) ? 0 : get_mutex_lock(v1, 1); #endif #ifdef DEBUG - log_msg(ZVLP_INFO, "vect_move: --- begin ---\n"); + LOG_MOD(ZVLP_INFO, "vect_move: --- begin ---\n"); #if (ZVECT_THREAD_SAFE == 1) - log_msg(ZVLP_INFO, "vect_move: lock_owner1 for vector v1: %*u\n", 10, lock_owner1); - log_msg(ZVLP_INFO, "vect_move: lock_owner2 for vector v2: %*u\n", 10, lock_owner2); + LOG_MOD(ZVLP_INFO, "vect_move: lock_owner1 for vector v1: %*u\n", 10, lock_owner1); + LOG_MOD(ZVLP_INFO, "vect_move: lock_owner2 for vector v2: %*u\n", 10, lock_owner2); #endif // ZVECT_THREAD_SAFE #endif @@ -3117,7 +3123,7 @@ DONE_PROCESSING: } #endif #ifdef DEBUG - log_msg(ZVLP_INFO, "vect_move: --- end ---\n"); + LOG_MOD(ZVLP_INFO, "vect_move: --- end ---\n"); #endif JOB_DONE: @@ -3125,11 +3131,12 @@ JOB_DONE: p_throw_error(rval, NULL); } } + ///////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// // vect_move_if moves a portion of a vector (v2) into another (v1) if f2 is true: -zvect_retval vect_move_if(c_vector const v1, +zvect_retval vect_move_if(c_vector const v1, c_vector v2, const zvect_index s2, const zvect_index e2, @@ -3146,10 +3153,10 @@ zvect_retval vect_move_if(c_vector const v1, zvect_retval lock_owner1 = (locking_disabled || (v1->flags & ZV_NOLOCKING)) ? 0 : get_mutex_lock(v1, 1); #endif #ifdef DEBUG - log_msg(ZVLP_INFO, "vect_move_if: --- begin ---\n"); + LOG_MOD(ZVLP_INFO, "vect_move_if: --- begin ---\n"); #if (ZVECT_THREAD_SAFE == 1) - log_msg(ZVLP_INFO, "vect_move_if: lock_owner1 for vector v1: %*u\n", 10, lock_owner1); - log_msg(ZVLP_INFO, "vect_move_if: lock_owner2 for vector v2: %*u\n", 10, lock_owner2); + LOG_MOD(ZVLP_INFO, "vect_move_if: lock_owner1 for vector v1: %*u\n", 10, lock_owner1); + LOG_MOD(ZVLP_INFO, "vect_move_if: lock_owner2 for vector v2: %*u\n", 10, lock_owner2); #endif // ZVECT_THREAD_SAFE #endif @@ -3174,7 +3181,7 @@ DONE_PROCESSING: } #endif #ifdef DEBUG - log_msg(ZVLP_INFO, "vect_move_if: --- end ---\n"); + LOG_MOD(ZVLP_INFO, "vect_move_if: --- end ---\n"); #endif JOB_DONE: @@ -3184,13 +3191,14 @@ JOB_DONE: return rval; } + ///////////////////////////////////////////////////////////////// #if (ZVECT_THREAD_SAFE == 1) ///////////////////////////////////////////////////////////////// // vect_move_on_signal -zvect_retval vect_move_on_signal(c_vector const v1, +zvect_retval vect_move_on_signal(c_vector const v1, c_vector v2, const zvect_index s2, const zvect_index e2, @@ -3207,7 +3215,7 @@ zvect_retval vect_move_on_signal(c_vector const v1, zvect_retval lock_owner1 = (locking_disabled || (v1->flags & ZV_NOLOCKING)) ? 0 : get_mutex_lock(v1, 1); #ifdef DEBUG - log_msg(ZVLP_MEDIUM, "vect_move_on_signal: --- start waiting ---\n"); + LOG_MOD(ZVLP_MEDIUM, "vect_move_on_signal: --- start waiting ---\n"); #endif // wait until we get a signal while (!(*f2)(v1, v2) && !(v2->status && (bool)ZVS_USR1_FLAG)) { @@ -3217,34 +3225,34 @@ zvect_retval vect_move_on_signal(c_vector const v1, //v2->status |= ZVS_USR_FLAG; #ifdef DEBUG - log_msg(ZVLP_MEDIUM, "Set status flag: %*i\n", 10, vect_check_status(v2, 1)); + LOG_MOD(ZVLP_MEDIUM, "Set status flag: %*i\n", 10, vect_check_status(v2, 1)); - log_msg(ZVLP_MEDIUM, "vect_move_on_signal: --- received signal ---\n"); + LOG_MOD(ZVLP_MEDIUM, "vect_move_on_signal: --- received signal ---\n"); - log_msg(ZVLP_MEDIUM, "vect_move_on_signal: --- begin ---\n"); + LOG_MOD(ZVLP_MEDIUM, "vect_move_on_signal: --- begin ---\n"); #endif // Proceed with move items: rval = p_vect_move(v1, v2, s2, e2); #ifdef DEBUG - log_msg(ZVLP_MEDIUM, "vect_move_on_signal: --- end ---\n"); + LOG_MOD(ZVLP_MEDIUM, "vect_move_on_signal: --- end ---\n"); #endif v2->status &= ~(ZVS_USR1_FLAG); #ifdef DEBUG - log_msg(ZVLP_MEDIUM, "Reset status flag: %*i\n", 10, vect_check_status(v2, 1)); + LOG_MOD(ZVLP_MEDIUM, "Reset status flag: %*i\n", 10, vect_check_status(v2, 1)); #endif //DONE_PROCESSING: #ifdef DEBUG - log_msg(ZVLP_MEDIUM, "v1 owner? %*i\n", 10, lock_owner1); + LOG_MOD(ZVLP_MEDIUM, "v1 owner? %*i\n", 10, lock_owner1); #endif if (lock_owner1) { get_mutex_unlock(v1, 1); } #ifdef DEBUG - log_msg(ZVLP_MEDIUM, "v2 owner? %*i\n", 10, lock_owner2); + LOG_MOD(ZVLP_MEDIUM, "v2 owner? %*i\n", 10, lock_owner2); #endif rval = p_vect_delete_at(v2, s2, e2 - 1, 0); if (lock_owner2) { @@ -3276,10 +3284,10 @@ void vect_merge(c_vector const v1, c_vector v2) { #endif #ifdef DEBUG - log_msg(ZVLP_INFO, "vect_merge: --- begin ---\n"); + LOG_MOD(ZVLP_INFO, "vect_merge: --- begin ---\n"); #if (ZVECT_THREAD_SAFE == 1) - log_msg(ZVLP_INFO, "vect_merge: lock_owner1 for vector v1: %*u\n", 10, lock_owner1); - log_msg(ZVLP_INFO, "vect_merge: lock_owner2 for vector v2: %*u\n", 10, lock_owner2); + LOG_MOD(ZVLP_INFO, "vect_merge: lock_owner1 for vector v1: %*u\n", 10, lock_owner1); + LOG_MOD(ZVLP_INFO, "vect_merge: lock_owner2 for vector v2: %*u\n", 10, lock_owner2); #endif // ZVECT_THREAD_SAFE #endif // DEBUG @@ -3296,7 +3304,7 @@ void vect_merge(c_vector const v1, c_vector v2) { } #ifdef DEBUG - log_msg(ZVLP_INFO, + LOG_MOD(ZVLP_INFO, "vect_merge: v2 capacity = %*u, begin = %*u, end: %*u, size = %*u\n", 10, p_vect_capacity(v2), @@ -3306,7 +3314,7 @@ void vect_merge(c_vector const v1, c_vector v2) { v2->end, 10, p_vect_size(v2)); - log_msg(ZVLP_INFO, + LOG_MOD(ZVLP_INFO, "vect_merge: v1 capacity = %*u, begin = %*u, end: %*u, size = %*u\n", 10, p_vect_capacity(v1), @@ -3324,7 +3332,7 @@ void vect_merge(c_vector const v1, c_vector v2) { } #ifdef DEBUG - log_msg(ZVLP_INFO, + LOG_MOD(ZVLP_INFO, "vect_merge: v1 capacity = %*u, begin = %*u, end: %*u, size = %*u\n", 10, p_vect_capacity(v1), @@ -3343,7 +3351,7 @@ void vect_merge(c_vector const v1, c_vector v2) { v1->end += p_vect_size(v2); #ifdef DEBUG - log_msg(ZVLP_INFO, + LOG_MOD(ZVLP_INFO, "vect_merge: v1 capacity = %*u, begin = %*u, end: %*u, size = %*u\n", 10, p_vect_capacity(v1), @@ -3376,7 +3384,7 @@ DONE_PROCESSING: // free memory correctly. #endif #ifdef DEBUG - log_msg(ZVLP_INFO, "vect_merge: --- end ---\n"); + LOG_MOD(ZVLP_INFO, "vect_merge: --- end ---\n"); #endif JOB_DONE: @@ -3384,6 +3392,7 @@ JOB_DONE: p_throw_error(rval, NULL); } } + // END of vect_merge #endif diff --git a/srcs/libs/mq/mq_data.c b/srcs/libs/mq/mq_data.c index 6bdd95e..e6e2cbb 100644 --- a/srcs/libs/mq/mq_data.c +++ b/srcs/libs/mq/mq_data.c @@ -300,7 +300,7 @@ static void process_data_msg(void *UNUSED(pDataCh), zmq_msg_t *pMsg) { memset(pBuf, 0, size); memcpy(pBuf, zmq_msg_data(pMsg), size - 1); - LOG_MSG(info, ZLOG_MOD_MQ, "receive(%zu): %s\n", strlen(pdata), pBuf); + LOG_MOD(info, ZLOG_MOD_MQ, "receive(%zu): %s\n", strlen(pdata), pBuf); zmq_msg_close(pMsg); @@ -309,7 +309,7 @@ static void process_data_msg(void *UNUSED(pDataCh), zmq_msg_t *pMsg) { if (pMqMsg) { if (strcmp(AGENT_CMD_ADDUSER, pMqMsg->message) == 0) { PMQ_DATA_ADD_USER p = NULL; - LOG_MSG(debug, ZLOG_MOD_MQ, "Process: %s\n", pMqMsg->params); + LOG_MOD(debug, ZLOG_MOD_MQ, "Process: %s\n", pMqMsg->params); decode_add_user_msg(pMqMsg->params, &p); if (p) { #ifdef LWIP_ON @@ -338,7 +338,7 @@ static void process_data_msg(void *UNUSED(pDataCh), zmq_msg_t *pMsg) { } } else if (strcmp(AGENT_CMD_REMOVUSER, pMqMsg->message) == 0) { PMQ_DATA_REMOVE_USER p = NULL; - LOG_MSG(debug, ZLOG_MOD_MQ, "Process: %s\n", pMqMsg->params); + LOG_MOD(debug, ZLOG_MOD_MQ, "Process: %s\n", pMqMsg->params); decode_remove_user_msg(pMqMsg->params, &p); @@ -362,7 +362,7 @@ int mq_data_send_msg(const char *pMsg) { zmq_msg_t msg; if (pMsg) { - LOG_MSG(debug, ZLOG_MOD_MQ, "Send PPPoE Session: %s\n", pMsg); + LOG_MOD(debug, ZLOG_MOD_MQ, "Send PPPoE Session: %s\n", pMsg); zmq_msg_init_size(&msg, strlen(pMsg) + 1); memset(zmq_msg_data(&msg), 0, strlen(pMsg) + 1); memcpy(zmq_msg_data(&msg), pMsg, strlen(pMsg)); @@ -407,7 +407,7 @@ int mq_data_init() { memset(buf, 0, 1024); sprintf(buf, "%s", cfg_get_zero_mq_data_path()); - LOG_MSG(info, ZLOG_MOD_MQ, "Start message queue connect: %s\n", buf); + LOG_MOD(info, ZLOG_MOD_MQ, "Start message queue connect: %s\n", buf); if (zmq_connect(g_pDataCh, buf) != 0) { zmq_close(g_pDataCh); diff --git a/srcs/libs/mq/msg_queue.c b/srcs/libs/mq/msg_queue.c index 6224795..57de58f 100644 --- a/srcs/libs/mq/msg_queue.c +++ b/srcs/libs/mq/msg_queue.c @@ -23,7 +23,7 @@ static void process_msg(zmq_msg_t *pMsg) { zmq_msg_t msg; const char *pRecMsg = strdup((const char *)zmq_msg_data(pMsg)); - LOG_MSG(info, ZLOG_MOD_MQ, "receive(%zu): %s\n", zmq_msg_size(pMsg), pRecMsg); + LOG_MOD(info, ZLOG_MOD_MQ, "receive(%zu): %s\n", zmq_msg_size(pMsg), pRecMsg); zmq_msg_close(pMsg); pResp = on_msg_cmd(pRecMsg); @@ -94,7 +94,7 @@ int mq_init(void) { memset(buf, 0, 1024); sprintf(buf, "tcp://*:%d", cfg_get_zero_mq_port()); - LOG_MSG(info, ZLOG_MOD_MQ, "Start message queue server: tcp://*:%d\n", cfg_get_zero_mq_port()); + LOG_MOD(info, ZLOG_MOD_MQ, "Start message queue server: tcp://*:%d\n", cfg_get_zero_mq_port()); if (zmq_bind(g_pResponse, buf) != 0) { zmq_close(g_pResponse); diff --git a/srcs/libs/network/inet_misc.c b/srcs/libs/network/inet_misc.c index 74971a2..55c0c7a 100644 --- a/srcs/libs/network/inet_misc.c +++ b/srcs/libs/network/inet_misc.c @@ -95,7 +95,7 @@ static void uvFsCloseCb(uv_fs_t *puvFs) { PHTTP_REQ_PARAMS pParams = (PHTTP_REQ_PARAMS)puvFs->data; if (puvFs->result < 0) { - LOG_MSG(error, ZLOG_MOD_NET, "Error: %zd\n", puvFs->result); + LOG_MOD(error, ZLOG_MOD_NET, "Error: %zd\n", puvFs->result); } uv_fs_req_cleanup(puvFs); @@ -136,7 +136,7 @@ static void uvFsDataSyncCb(uv_fs_t *puvFs) { PHTTP_REQ_PARAMS pParams = (PHTTP_REQ_PARAMS)puvFs->data; if (puvFs->result < 0) { - LOG_MSG(error, ZLOG_MOD_NET, "Error: %zd\n", puvFs->result); + LOG_MOD(error, ZLOG_MOD_NET, "Error: %zd\n", puvFs->result); } uv_fs_req_cleanup(puvFs); @@ -150,7 +150,7 @@ static PCURL_CONTEXT_DATA createCurlContext(curl_socket_t sock) { pContext->sock = sock; if (uv_poll_init_socket(get_task_manager(), &pContext->uvPool, sock) != 0) { - LOG_MSG(error, ZLOG_MOD_NET, "uv_poll_init_socket Error\n"); + LOG_MOD(error, ZLOG_MOD_NET, "uv_poll_init_socket Error\n"); } pContext->uvPool.data = pContext; @@ -168,7 +168,7 @@ static void checkMultiInfoTimeout(void) { case CURLMSG_DONE: curl_easy_getinfo(pMsg->easy_handle, CURLINFO_PRIVATE, (void *)&pReq); - LOG_MSG(error, ZLOG_MOD_NET, "Cleanup CURL: %p\n", pMsg->easy_handle); + LOG_MOD(error, ZLOG_MOD_NET, "Cleanup CURL: %p\n", pMsg->easy_handle); curl_multi_remove_handle(g_pCurl, pMsg->easy_handle); curl_easy_cleanup(pMsg->easy_handle); @@ -202,7 +202,7 @@ static void checkMultiInfoTimeout(void) { break; default: - LOG_MSG(error, ZLOG_MOD_NET, "pMsg->msg(%d) != CURLMSG_DONE\n", pMsg->msg); + LOG_MOD(error, ZLOG_MOD_NET, "pMsg->msg(%d) != CURLMSG_DONE\n", pMsg->msg); return; } } @@ -219,7 +219,7 @@ static void checkMultiInfo(void) { curl_easy_getinfo(pMsg->easy_handle, CURLINFO_PRIVATE, (void *)&pReq); curl_multi_remove_handle(g_pCurl, pMsg->easy_handle); - LOG_MSG(debug, ZLOG_MOD_NET, "Cleanup CURL: %p\n", pMsg->easy_handle); + LOG_MOD(debug, ZLOG_MOD_NET, "Cleanup CURL: %p\n", pMsg->easy_handle); curl_easy_cleanup(pMsg->easy_handle); if (pReq) { @@ -302,7 +302,7 @@ static void checkMultiInfo(void) { break; default: - LOG_MSG(error, ZLOG_MOD_NET, "pMsg->msg(%d) != CURLMSG_DONE\n", pMsg->msg); + LOG_MOD(error, ZLOG_MOD_NET, "pMsg->msg(%d) != CURLMSG_DONE\n", pMsg->msg); return; } } @@ -449,7 +449,7 @@ static int progressCb(void *pData, double total, double now, double UNUSED(ulTot } if (pParams->isCancel) { - LOG_MSG(error, ZLOG_MOD_NET, "Cancel Download: %s\n", pParams->pTaskUuid); + LOG_MOD(error, ZLOG_MOD_NET, "Cancel Download: %s\n", pParams->pTaskUuid); return (-CURLE_OPERATION_TIMEDOUT); } @@ -498,7 +498,7 @@ static void onDlTimeoutCb(uv_timer_t *UNUSED(pufTimer)) { // 下载时间大于10s且平均下载速度小于10K/s超时 if ((dlTime * 10000 > pItem->pCurlItem->dlSize) && dlTime > 10) { - LOG_MSG(error, + LOG_MOD(error, ZLOG_MOD_NET, "Download Speed less than 10k/s: %s (%uK/%llu(s))\n", pItem->pTaskUuid, @@ -521,7 +521,7 @@ static void onDlTimeoutCb(uv_timer_t *UNUSED(pufTimer)) { // 5分钟内没有下载任何数据超时 if (pItem->pCurlItem->lastTm > 0) { if (curTm > pItem->pCurlItem->lastTm + MAX_TIMEOUT_VALUE) { - LOG_MSG(error, ZLOG_MOD_NET, "Download Timeout: %s\n", pItem->pTaskUuid); + LOG_MOD(error, ZLOG_MOD_NET, "Download Timeout: %s\n", pItem->pTaskUuid); cancelDownloadTask(pItem->pCurlItem); if (pItem->pCurlItem->onRspCb) { pItem->pCurlItem->onRspCb(NULL, @@ -538,7 +538,7 @@ static void onDlTimeoutCb(uv_timer_t *UNUSED(pufTimer)) { // 下载最长时间设置为1800秒(60分钟) if (dlTime > 3600) { - LOG_MSG(error, + LOG_MOD(error, ZLOG_MOD_NET, "Download More than 1800 seconds: %s (%uK/%llu(s))\n", pItem->pTaskUuid, @@ -599,7 +599,7 @@ const char *inet_download_file_async(const char *pURL, return (NULL); } - LOG_MSG(debug, ZLOG_MOD_NET, "Begin Download: %s --> %s\n", pURL, pPath); + LOG_MOD(debug, ZLOG_MOD_NET, "Begin Download: %s --> %s\n", pURL, pPath); pParams = (PHTTP_REQ_PARAMS)malloc(sizeof(HTTP_REQ_PARAMS)); @@ -643,7 +643,7 @@ const char *inet_download_file_async(const char *pURL, pParams->uvFsDataSync.data = pParams; pParams->uvFsClose.data = pParams; - LOG_MSG(debug, + LOG_MOD(debug, ZLOG_MOD_NET, "[%s]: File %s used temp path %s\n", pParams->pTaskUuid, @@ -702,14 +702,14 @@ const char *inet_download_file_async(const char *pURL, curl_easy_setopt(pCurl, CURLOPT_SSL_VERIFYHOST, 0L); #endif - LOG_MSG(debug, ZLOG_MOD_NET, "Download(%u): %s --> %p\n", g_TotalDownloads++, pParams->pTaskUuid, pCurl); + LOG_MOD(debug, ZLOG_MOD_NET, "Download(%u): %s --> %p\n", g_TotalDownloads++, pParams->pTaskUuid, pCurl); ret = curl_multi_add_handle(g_pCurl, pCurl); if (ret == CURLE_OK) { addReqIdToTable(pParams->pTaskUuid, pParams); return (pParams->pTaskUuid); } else { free(pParams->pTaskUuid); - LOG_MSG(error, ZLOG_MOD_NET, "Add Handle Error: %d\n", ret); + LOG_MOD(error, ZLOG_MOD_NET, "Add Handle Error: %d\n", ret); return NULL; } } @@ -786,14 +786,14 @@ const char *inet_http_post_async(const char *pURL, const char *pPost, on_http_re curl_easy_setopt(pCurl, CURLOPT_SSL_VERIFYHOST, 0L); #endif - LOG_MSG(debug, ZLOG_MOD_NET, "Http POST(%u): %s --> %p\n", g_TotalDownloads++, pParams->pTaskUuid, pCurl); + LOG_MOD(debug, ZLOG_MOD_NET, "Http POST(%u): %s --> %p\n", g_TotalDownloads++, pParams->pTaskUuid, pCurl); ret = curl_multi_add_handle(g_pCurl, pCurl); if (ret == CURLE_OK) { addReqIdToTable(pParams->pTaskUuid, pParams); return (pParams->pTaskUuid); } else { free(pParams->pTaskUuid); - LOG_MSG(error, ZLOG_MOD_NET, "Add Handle Error: %d\n", ret); + LOG_MOD(error, ZLOG_MOD_NET, "Add Handle Error: %d\n", ret); return NULL; } } @@ -804,7 +804,7 @@ int inet_api_init(void) { ret = curl_global_init(CURL_GLOBAL_ALL); if (ret != 0) { - LOG_MSG(error, ZLOG_MOD_NET, "curl init error: %d\n", ret); + LOG_MOD(error, ZLOG_MOD_NET, "curl init error: %d\n", ret); return ret; } diff --git a/srcs/libs/protocol/protocol.c b/srcs/libs/protocol/protocol.c index fed8e1f..9ab740f 100644 --- a/srcs/libs/protocol/protocol.c +++ b/srcs/libs/protocol/protocol.c @@ -161,7 +161,7 @@ const char *proto_create_new(cJSON *pMsgCtx, int httpCode) { } if (pKey == NULL || strlen(pKey) == 0) { - LOG_MSG(error, + LOG_MOD(error, ZLOG_MOD_PROTO, "Cryptography key empty of algorithm %d, Used default algorithm BASE64\n", cryptoType); @@ -175,7 +175,7 @@ const char *proto_create_new(cJSON *pMsgCtx, int httpCode) { ret = symmetric_encrypto(cryptoType, (unsigned char *)pStrMsg, strlen(pStrMsg), &buf, &outSize, pKey); if (ret != ERR_SUCCESS) { - LOG_MSG(error, + LOG_MOD(error, ZLOG_MOD_PROTO, "Unsupported protocol crypto : %d, Used default algorithm BASE64\n", cryptoType); @@ -191,7 +191,7 @@ const char *proto_create_new(cJSON *pMsgCtx, int httpCode) { cJSON_free(pro.msgContend); } break; default: - LOG_MSG(error, + LOG_MOD(error, ZLOG_MOD_PROTO, "Unsupported protocol crypto algorithms: %d, Used default algorithm BASE64\n", pro.cryptoType); @@ -201,7 +201,7 @@ const char *proto_create_new(cJSON *pMsgCtx, int httpCode) { } pStrProto = cJSON_Print(pRoot); - LOG_MSG(debug, ZLOG_MOD_PROTO, "Create: \n%s\n", pStrProto); + LOG_MOD(debug, ZLOG_MOD_PROTO, "Create: \n%s\n", pStrProto); cJSON_Delete(pRoot); diff --git a/srcs/libs/task/task_manager.c b/srcs/libs/task/task_manager.c index d2fcb96..869aa6c 100644 --- a/srcs/libs/task/task_manager.c +++ b/srcs/libs/task/task_manager.c @@ -84,6 +84,6 @@ void task_manager_run() { free(pCtx); } - LOG_MSG(info, ZLOG_MOD_TASK, "Main task exited..............\n"); + LOG_MOD(info, ZLOG_MOD_TASK, "Main task exited..............\n"); g_isSystemExit = TRUE; } \ No newline at end of file diff --git a/srcs/libs/zlog_module/zlog_module.c b/srcs/libs/zlog_module/zlog_module.c index fafd384..d5cbda3 100644 --- a/srcs/libs/zlog_module/zlog_module.c +++ b/srcs/libs/zlog_module/zlog_module.c @@ -7,7 +7,7 @@ typedef struct { ZLOG_MOD_NAME logModule; zlog_category_t *pCat; char catName[MAX_ZLOG_MOD_LEN]; -} ZLOG_MODULE, *PZLOG_MODULE; +} ZLOG_MODULE; static ZLOG_MODULE g_zlogModule[] = { {ZLOG_MOD_MAIN, NULL, "MAIN" }, diff --git a/srcs/lwip/src/arch_linux/core/vxlan_pkg.c b/srcs/lwip/src/arch_linux/core/vxlan_pkg.c index 6f70d39..778a401 100644 --- a/srcs/lwip/src/arch_linux/core/vxlan_pkg.c +++ b/srcs/lwip/src/arch_linux/core/vxlan_pkg.c @@ -213,7 +213,7 @@ static void vxlan_pkg_head_init(PVXLAN_PKG_HEAD pvxLan) { int vxlan_peer_add(const char *pIp, const char *pMac) { if (!VERIFY_STRING(pIp) || !VERIFY_STRING(pMac)) { - LOG_MSG(error, + LOG_MOD(error, ZLOG_MOD_VXLAN, "Input parameters error: %s, %s\n", SAFETY_STR_STRING(pIp), @@ -229,7 +229,7 @@ int vxlan_peer_add(const char *pIp, const char *pMac) { str_to_mac(pMac, peerMac); if (str_to_ipaddr(pIp, &peerIp) == 0) { - LOG_MSG(error, ZLOG_MOD_VXLAN, "Get vxLan peer ip address failed: %s\n", pIp); + LOG_MOD(error, ZLOG_MOD_VXLAN, "Get vxLan peer ip address failed: %s\n", pIp); return -ERR_SYS_INIT; } @@ -248,7 +248,7 @@ int vxlan_peer_add(const char *pIp, const char *pMac) { // 对发送报文的头部进行初始化 vxlan_pkg_head_init(pkg); - LOG_MSG(debug, ZLOG_MOD_VXLAN, "Add vxLan Link: vSwitch: %s, %s\n", pIp, pMac); + LOG_MOD(debug, ZLOG_MOD_VXLAN, "Add vxLan Link: vSwitch: %s, %s\n", pIp, pMac); } return ERR_SUCCESS; @@ -256,7 +256,7 @@ int vxlan_peer_add(const char *pIp, const char *pMac) { int vxlan_link_init(const char *pEthName) { if (!VERIFY_STRING(pEthName)) { - LOG_MSG(error, ZLOG_MOD_VXLAN, "Input parameters error: %s\n", SAFETY_STR_STRING(pEthName)); + LOG_MOD(error, ZLOG_MOD_VXLAN, "Input parameters error: %s\n", SAFETY_STR_STRING(pEthName)); return -ERR_INPUT_PARAMS; } @@ -271,7 +271,7 @@ int vxlan_link_init(const char *pEthName) { &g_vxLanLinks.nic_info.ip_mask, &g_vxLanLinks.nic_info.ip_gw, g_vxLanLinks.nic_info.mac) != ERR_SUCCESS) { - LOG_MSG(error, ZLOG_MOD_VXLAN, "Get NIC information failed\n"); + LOG_MOD(error, ZLOG_MOD_VXLAN, "Get NIC information failed\n"); return -ERR_SYS_INIT; } diff --git a/srcs/lwip/src/arch_linux/include/netif/pppoeif.h b/srcs/lwip/src/arch_linux/include/netif/pppoeif.h index ce58609..9b6ed94 100644 --- a/srcs/lwip/src/arch_linux/include/netif/pppoeif.h +++ b/srcs/lwip/src/arch_linux/include/netif/pppoeif.h @@ -38,11 +38,11 @@ #define DUMP_IF_BUF(tag, buf, len) \ do { \ - LOG_MSG(debug, ZLOG_MOD_LWIP, "%s ++++++\n", (tag)); \ + LOG_MOD(debug, ZLOG_MOD_LWIP, "%s ++++++\n", (tag)); \ printf("\n"); \ - LOG_MSG_HEX(debug, ZLOG_MOD_LWIP, (buf), (len)); \ + LOG_MOD_HEX(debug, ZLOG_MOD_LWIP, (buf), (len)); \ printf("\n"); \ - LOG_MSG(debug, ZLOG_MOD_LWIP, "%s ------\n", (tag)); \ + LOG_MOD(debug, ZLOG_MOD_LWIP, "%s ------\n", (tag)); \ } while (0) #ifdef __cplusplus diff --git a/srcs/lwip/src/arch_linux/netif/pcapif.c b/srcs/lwip/src/arch_linux/netif/pcapif.c index 1d78bc6..5ef8c36 100644 --- a/srcs/lwip/src/arch_linux/netif/pcapif.c +++ b/srcs/lwip/src/arch_linux/netif/pcapif.c @@ -133,7 +133,7 @@ static void pcap_pkg_cb(unsigned char *args, const struct pcap_pkthdr *pkthdr, c memcpy(zmq_msg_data(&msg), packet, pkthdr->caplen); rc = zmq_msg_send(&msg, pcapif->msg_input, 0); if (rc == -1) { - LOG_MSG(error, ZLOG_MOD_LWIP, "Send %d bytes message error: %s\n", pkthdr->caplen, strerror(errno)); + LOG_MOD(error, ZLOG_MOD_LWIP, "Send %d bytes message error: %s\n", pkthdr->caplen, strerror(errno)); } zmq_msg_close(&msg); } @@ -286,7 +286,7 @@ _Noreturn static void pcapif_thread(void *arg) { static void status_callback(struct netif *state_netif) { if (netif_is_up(state_netif)) { #if LWIP_IPV4 - LOG_MSG(info, + LOG_MOD(info, ZLOG_MOD_LWIP, "status_callback==UP, local interface IP is %s\n", ip4addr_ntoa(netif_ip4_addr(state_netif))); @@ -294,7 +294,7 @@ static void status_callback(struct netif *state_netif) { printf("status_callback==UP\n"); #endif } else { - LOG_MSG(error, ZLOG_MOD_LWIP, "status_callback==DOWN\n"); + LOG_MOD(error, ZLOG_MOD_LWIP, "status_callback==DOWN\n"); } } #endif /* LWIP_NETIF_STATUS_CALLBACK */ @@ -302,9 +302,9 @@ static void status_callback(struct netif *state_netif) { #if LWIP_NETIF_LINK_CALLBACK static void link_callback(struct netif *state_netif) { if (netif_is_link_up(state_netif)) { - LOG_MSG(info, ZLOG_MOD_LWIP, "link_callback==UP\n"); + LOG_MOD(info, ZLOG_MOD_LWIP, "link_callback==UP\n"); } else { - LOG_MSG(error, ZLOG_MOD_LWIP, "link_callback==DOWN\n"); + LOG_MOD(error, ZLOG_MOD_LWIP, "link_callback==DOWN\n"); } } #endif /* LWIP_NETIF_LINK_CALLBACK */ @@ -392,7 +392,7 @@ struct netif *bind_pcap_if(const char *eth_name, const char *pkg_filter, int vxl struct pcapif *pcapif = (struct pcapif *)mem_malloc(sizeof(struct pcapif)); if (pcapif == NULL) { - LOG_MSG(error, ZLOG_MOD_LWIP, "bind_pcapsocket_if: out of memory for pcapif\n"); + LOG_MOD(error, ZLOG_MOD_LWIP, "bind_pcapsocket_if: out of memory for pcapif\n"); return NULL; } @@ -401,7 +401,7 @@ struct netif *bind_pcap_if(const char *eth_name, const char *pkg_filter, int vxl if (vxlan_support) { if (vxlan_link_init(eth_name) != ERR_OK) { - LOG_MSG(error, ZLOG_MOD_LWIP, "bind_pcapsocket_if: Get local nic info failed\n"); + LOG_MOD(error, ZLOG_MOD_LWIP, "bind_pcapsocket_if: Get local nic info failed\n"); free(pcapif); return NULL; } @@ -420,15 +420,15 @@ struct netif *bind_pcap_if(const char *eth_name, const char *pkg_filter, int vxl pPcap = pcap_open_live(pcapif->eth_name, MAX_BYTES_PACKAGE, 1, -1, errBuf); if (get_nic_info(eth_name, &ipaddr, &netmask, &gw, mac) != ERR_OK) { - LOG_MSG(error, ZLOG_MOD_LWIP, "Get NIC %s information error\n", eth_name); + LOG_MOD(error, ZLOG_MOD_LWIP, "Get NIC %s information error\n", eth_name); } - LOG_MSG(debug, ZLOG_MOD_LWIP, "Pcap netif used filter: \"%s\"\n", pcapif->pkg_filter); + LOG_MOD(debug, ZLOG_MOD_LWIP, "Pcap netif used filter: \"%s\"\n", pcapif->pkg_filter); if (pcap_compile(pPcap, &filter, pcapif->pkg_filter, 1, netmask) == -1) { - LOG_MSG(error, ZLOG_MOD_LWIP, "Set package fileter[%s] error: %s\n", pcapif->pkg_filter, pcap_geterr(pPcap)); + LOG_MOD(error, ZLOG_MOD_LWIP, "Set package fileter[%s] error: %s\n", pcapif->pkg_filter, pcap_geterr(pPcap)); } if (pcap_setfilter(pPcap, &filter) == -1) { - LOG_MSG(error, ZLOG_MOD_LWIP, "Set package fileter[%s] error: %s\n", pcapif->pkg_filter, pcap_geterr(pPcap)); + LOG_MOD(error, ZLOG_MOD_LWIP, "Set package fileter[%s] error: %s\n", pcapif->pkg_filter, pcap_geterr(pPcap)); } pcapif->pcap = pPcap; @@ -454,7 +454,7 @@ struct netif *bind_pcap_if(const char *eth_name, const char *pkg_filter, int vxl if (!netif) { mem_free(pcapif); - LOG_MSG(error, ZLOG_MOD_LWIP, "Create netif error\n"); + LOG_MOD(error, ZLOG_MOD_LWIP, "Create netif error\n"); return NULL; } diff --git a/srcs/lwip/src/arch_linux/netif/pppoe_if.c b/srcs/lwip/src/arch_linux/netif/pppoe_if.c index b861a98..4b993d2 100644 --- a/srcs/lwip/src/arch_linux/netif/pppoe_if.c +++ b/srcs/lwip/src/arch_linux/netif/pppoe_if.c @@ -162,12 +162,12 @@ err_t pppoeif_init(struct netif *netif) { static void status_callback(struct netif *state_netif) { if (netif_is_up(state_netif)) { #if LWIP_IPV4 - LOG_MSG(info, ZLOG_MOD_LWIP, ("status_callback==UP, local interface IP is %s\n", ip4addr_ntoa(netif_ip4_addr(state_netif))); + LOG_MOD(info, ZLOG_MOD_LWIP, ("status_callback==UP, local interface IP is %s\n", ip4addr_ntoa(netif_ip4_addr(state_netif))); #else printf("status_callback==UP\n"); #endif } else { - LOG_MSG(error, ZLOG_MOD_LWIP, ("status_callback==DOWN\n"); + LOG_MOD(error, ZLOG_MOD_LWIP, ("status_callback==DOWN\n"); } } #endif /* LWIP_NETIF_STATUS_CALLBACK */ @@ -175,9 +175,9 @@ static void status_callback(struct netif *state_netif) { #if LWIP_NETIF_LINK_CALLBACK static void link_callback(struct netif *state_netif) { if (netif_is_link_up(state_netif)) { - LOG_MSG(info, ZLOG_MOD_LWIP, ("link_callback==UP\n"); + LOG_MOD(info, ZLOG_MOD_LWIP, ("link_callback==UP\n"); } else { - LOG_MSG(error, ZLOG_MOD_LWIP, ("link_callback==DOWN\n"); + LOG_MOD(error, ZLOG_MOD_LWIP, ("link_callback==DOWN\n"); } } #endif /* LWIP_NETIF_LINK_CALLBACK */ @@ -207,7 +207,7 @@ struct netif *create_pppoe_if(PUSER_INFO_CONTEXT pUser) { netif = (struct netif *)mem_malloc(sizeof(struct netif)); if (!netif) { - LOG_MSG(error, ZLOG_MOD_LWIP, ("Create PPPoE netif error\n"); + LOG_MOD(error, ZLOG_MOD_LWIP, ("Create PPPoE netif error\n"); return NULL; } diff --git a/srcs/lwip/src/arch_linux/netif/rawif.c b/srcs/lwip/src/arch_linux/netif/rawif.c index e34c667..1a8e440 100644 --- a/srcs/lwip/src/arch_linux/netif/rawif.c +++ b/srcs/lwip/src/arch_linux/netif/rawif.c @@ -289,7 +289,7 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p) { unsigned short ip_len = udp_len + 20; unsigned int total_len = ip_len + sizeof(struct eth_hdr); - LOG_MSG(debug, ZLOG_MOD_LWIP, ("Found user vxlan connect: %d --> %u\n", pUser->userid, pvxlanBuf->vni); + LOG_MOD(debug, ZLOG_MOD_LWIP, ("Found user vxlan connect: %d --> %u\n", pUser->userid, pvxlanBuf->vni); memcpy(sndBuf, pvxlanBuf->output_head, sizeof(struct vxlan_package)); pkg->vxlan_head.vni_reserved = lwip_htonl(VXLAN_VIN_ID_PACK(pUser->vxlan.vni)); @@ -317,24 +317,24 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p) { if(memcmp(buf, p->payload, p->tot_len) != 0) { - LOG_MSG(debug, ZLOG_MOD_LWIP, ("INPKG +++++\n"); + LOG_MOD(debug, ZLOG_MOD_LWIP, ("INPKG +++++\n"); hLOG_MSG(debug, ZLOG_MOD_LWIP, (p->payload, p->tot_len); printf("\n"); - LOG_MSG(debug, ZLOG_MOD_LWIP, ("INPKG -----\n"); + LOG_MOD(debug, ZLOG_MOD_LWIP, ("INPKG -----\n"); - LOG_MSG(debug, ZLOG_MOD_LWIP, ("BUF +++++\n"); + LOG_MOD(debug, ZLOG_MOD_LWIP, ("BUF +++++\n"); hLOG_MSG(debug, ZLOG_MOD_LWIP, (buf, p->tot_len); printf("\n"); - LOG_MSG(debug, ZLOG_MOD_LWIP, ("BUF -----\n"); + LOG_MOD(debug, ZLOG_MOD_LWIP, ("BUF -----\n"); } #if 0 - LOG_MSG(debug, ZLOG_MOD_LWIP, ("OUTPKG +++++\n"); + LOG_MOD(debug, ZLOG_MOD_LWIP, ("OUTPKG +++++\n"); hLOG_MSG(debug, ZLOG_MOD_LWIP, (sndBuf, total_len); printf("\n"); - LOG_MSG(debug, ZLOG_MOD_LWIP, ("INPKG -----\n"); + LOG_MOD(debug, ZLOG_MOD_LWIP, ("INPKG -----\n"); #endif - LOG_MSG(debug, ZLOG_MOD_LWIP, ("In %u, out %u, send %zd\n", p->tot_len, total_len, written); + LOG_MOD(debug, ZLOG_MOD_LWIP, ("In %u, out %u, send %zd\n", p->tot_len, total_len, written); return written == (total_len) ? ERR_OK : ERR_IF; @@ -519,12 +519,12 @@ _Noreturn static void rawif_thread(void *arg) { static void status_callback(struct netif *state_netif) { if (netif_is_up(state_netif)) { #if LWIP_IPV4 - LOG_MSG(info, ZLOG_MOD_LWIP, ("status_callback==UP, local interface IP is %s\n", ip4addr_ntoa(netif_ip4_addr(state_netif))); + LOG_MOD(info, ZLOG_MOD_LWIP, ("status_callback==UP, local interface IP is %s\n", ip4addr_ntoa(netif_ip4_addr(state_netif))); #else printf("status_callback==UP\n"); #endif } else { - LOG_MSG(error, ZLOG_MOD_LWIP, ("status_callback==DOWN\n"); + LOG_MOD(error, ZLOG_MOD_LWIP, ("status_callback==DOWN\n"); } } #endif /* LWIP_NETIF_STATUS_CALLBACK */ @@ -532,9 +532,9 @@ static void status_callback(struct netif *state_netif) { #if LWIP_NETIF_LINK_CALLBACK static void link_callback(struct netif *state_netif) { if (netif_is_link_up(state_netif)) { - LOG_MSG(info, ZLOG_MOD_LWIP, ("link_callback==UP\n"); + LOG_MOD(info, ZLOG_MOD_LWIP, ("link_callback==UP\n"); } else { - LOG_MSG(error, ZLOG_MOD_LWIP, ("link_callback==DOWN\n"); + LOG_MOD(error, ZLOG_MOD_LWIP, ("link_callback==DOWN\n"); } } #endif /* LWIP_NETIF_LINK_CALLBACK */ @@ -696,7 +696,7 @@ static err_t netif_input_data(struct pbuf *p, struct netif *inp) { pbuf_free(p); return err; } else { - LOG_MSG(error, ZLOG_MOD_LWIP, ("Not found: %u, %u, %u\n", tag.vni, tag.q1, tag.q2); + LOG_MOD(error, ZLOG_MOD_LWIP, ("Not found: %u, %u, %u\n", tag.vni, tag.q1, tag.q2); } #else VXLAN_TAG tag; @@ -726,7 +726,7 @@ static err_t netif_input_data(struct pbuf *p, struct netif *inp) { } if ((err = pContext->session.nicif->input(ebuf, pContext->session.nicif)) != ERR_OK) { - LOG_MSG(debug, ZLOG_MOD_LWIP, ("\n"); + LOG_MOD(debug, ZLOG_MOD_LWIP, ("\n"); LWIP_DEBUGF(NETIF_DEBUG, ("pppoeif_input: netif input error\n")); } @@ -759,7 +759,7 @@ struct netif *bind_rawsocket_if(const char *eth_name) { struct rawif *rawif = (struct rawif *)mem_malloc(sizeof(struct rawif)); if (rawif == NULL) { - LOG_MSG(error, ZLOG_MOD_LWIP, ("bind_rawsocket_if: out of memory for rawif\n"); + LOG_MOD(error, ZLOG_MOD_LWIP, ("bind_rawsocket_if: out of memory for rawif\n"); return NULL; } @@ -770,7 +770,7 @@ struct netif *bind_rawsocket_if(const char *eth_name) { } if (vxlan_link_init(eth_name) != ERR_OK) { - LOG_MSG(error, ZLOG_MOD_LWIP, ("bind_rawsocket_if: Get local nic info failed\n"); + LOG_MOD(error, ZLOG_MOD_LWIP, ("bind_rawsocket_if: Get local nic info failed\n"); return NULL; } @@ -808,7 +808,7 @@ struct netif *bind_rawsocket_if(const char *eth_name) { if (!netif) { mem_free(rawif); - LOG_MSG(error, ZLOG_MOD_LWIP, ("Create netif error\n"); + LOG_MOD(error, ZLOG_MOD_LWIP, ("Create netif error\n"); return NULL; } diff --git a/srcs/opendhcp183/opendhcpd.h b/srcs/opendhcp183/opendhcpd.h index 6bb995d..101c2a6 100644 --- a/srcs/opendhcp183/opendhcpd.h +++ b/srcs/opendhcp183/opendhcpd.h @@ -86,13 +86,13 @@ typedef struct in_pktinfo IN_PKTINFO; do { \ switch ((logLevel)) { \ case 2: \ - LOG_MSG(debug, ZLOG_MOD_OPENDHCPD, "%s\n", logBuff); \ + LOG_MOD(debug, ZLOG_MOD_OPENDHCPD, "%s\n", logBuff); \ break; \ case 0: \ - LOG_MSG(error, ZLOG_MOD_OPENDHCPD, "%s\n", logBuff); \ + LOG_MOD(error, ZLOG_MOD_OPENDHCPD, "%s\n", logBuff); \ break; \ default: \ - LOG_MSG(info, ZLOG_MOD_OPENDHCPD, "%s\n", logBuff); \ + LOG_MOD(info, ZLOG_MOD_OPENDHCPD, "%s\n", logBuff); \ break; \ } \ } while (0) diff --git a/srcs/opendhcp183/query.cpp b/srcs/opendhcp183/query.cpp index 869a0d0..89afac6 100644 --- a/srcs/opendhcp183/query.cpp +++ b/srcs/opendhcp183/query.cpp @@ -49,7 +49,7 @@ static int dhcp_get_user_info(data19 *req, const char *pRequest) { int k; dhcpMap::iterator p; - LOG_MSG(debug, ZLOG_MOD_OPENDHCPD, "Input: %s\n", pRequest); + LOG_MOD(debug, ZLOG_MOD_OPENDHCPD, "Input: %s\n", pRequest); if (pRequest == nullptr || strlen(pRequest) == 0) { sprintf(logBuff, "Requeset Json"); @@ -371,7 +371,7 @@ static int add_dhcpd_rangeset(data19 *req, const char *pRequest) { cJSON *pRspRoot; cJSON *pExpandArray; - LOG_MSG(debug, ZLOG_MOD_OPENDHCPD, "Input: %s\n", pRequest); + LOG_MOD(debug, ZLOG_MOD_OPENDHCPD, "Input: %s\n", pRequest); if (pRequest == nullptr || strlen(pRequest) == 0) { sprintf(logBuff, "Requeset Json"); @@ -489,7 +489,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) { hash_map *delMap = nullptr; int resCount = 0; - LOG_MSG(debug, ZLOG_MOD_OPENDHCPD, "Input: %s\n", pRequest); + LOG_MOD(debug, ZLOG_MOD_OPENDHCPD, "Input: %s\n", pRequest); if (pRequest == nullptr || strlen(pRequest) == 0) { sprintf(logBuff, "Requeset Json"); @@ -765,7 +765,7 @@ int getHwAddr(char *buff, char *mac) { int arpSet(const char *ifname, char *ipStr, char *mac) { if (ifname == nullptr || ipStr == nullptr || mac == nullptr) { - LOG_MSG(error, ZLOG_MOD_OPENDHCPD, "para is null.\n"); + LOG_MOD(error, ZLOG_MOD_OPENDHCPD, "para is null.\n"); return -1; } @@ -783,19 +783,19 @@ int arpSet(const char *ifname, char *ipStr, char *mac) { req.arp_flags = ATF_PERM | ATF_COM; if (getHwAddr((char *)req.arp_ha.sa_data, mac) < 0) { - LOG_MSG(error, ZLOG_MOD_OPENDHCPD, "get mac error.\n"); + LOG_MOD(error, ZLOG_MOD_OPENDHCPD, "get mac error.\n"); return -1; } sock_fd = socket(AF_INET, SOCK_DGRAM, 0); if (sock_fd < 0) { - LOG_MSG(error, ZLOG_MOD_OPENDHCPD, "get socket error.\n"); + LOG_MOD(error, ZLOG_MOD_OPENDHCPD, "get socket error.\n"); return -1; } ret = ioctl(sock_fd, SIOCSARP, &req); if (ret < 0) { - LOG_MSG(error, ZLOG_MOD_OPENDHCPD, "ioctl error.\n"); + LOG_MOD(error, ZLOG_MOD_OPENDHCPD, "ioctl error.\n"); close(sock_fd); return -1; } @@ -1207,11 +1207,11 @@ static void on_http_response_cb(void *pData, int iFinished, void *pUserData) { if (iFinished == 0) { - LOG_MSG(debug, ZLOG_MOD_OPENDHCPD, "Request(%s): [%s] Response: [%u] OK:\n", pTaskUuid, pReqUrl, size); + LOG_MOD(debug, ZLOG_MOD_OPENDHCPD, "Request(%s): [%s] Response: [%u] OK:\n", pTaskUuid, pReqUrl, size); } else if (iFinished == 1) { - LOG_MSG(error, ZLOG_MOD_OPENDHCPD, "Request(%s): [%s] Response: [%u] Error\n", pTaskUuid, pReqUrl, size); + LOG_MOD(error, ZLOG_MOD_OPENDHCPD, "Request(%s): [%s] Response: [%u] Error\n", pTaskUuid, pReqUrl, size); } else { - LOG_MSG(error, ZLOG_MOD_OPENDHCPD, "Download Error Code: %d\n", iFinished); + LOG_MOD(error, ZLOG_MOD_OPENDHCPD, "Download Error Code: %d\n", iFinished); } free(pUserData); @@ -1237,7 +1237,7 @@ void iptvCacheCb(void *UNUSED(pArg)) { isReport = true; // 添加到缓存列表供后续查询 HASH_ADD_STR(g_iptvCacheDevs, iptvMAC, pCacheDev); - LOG_MSG(debug, + LOG_MOD(debug, ZLOG_MOD_OPENDHCPD, "Add IPTV device %s vni %d to cache\n", pCacheDev->iptvMAC, @@ -1294,7 +1294,7 @@ void opendhcp_init_http_server() { added = TRUE; #ifdef USER_VNI - LOG_MSG(info, ZLOG_MOD_OPENDHCPD, "User VxLan Id: [%d]\n", cfg_get_user_vni_id()); + LOG_MOD(info, ZLOG_MOD_OPENDHCPD, "User VxLan Id: [%d]\n", cfg_get_user_vni_id()); #endif } } @@ -1322,7 +1322,7 @@ void opendhcp_add_ip_pool_set() { if (pRange) { if (dhcp_add_rangeset_to_options(pRange) != ERR_SUCCESS) { - LOG_MSG(error, ZLOG_MOD_OPENDHCPD, "Add rangeset(\"%s\") failed!\n", pRange->rangAddr); + LOG_MOD(error, ZLOG_MOD_OPENDHCPD, "Add rangeset(\"%s\") failed!\n", pRange->rangAddr); } } } @@ -1354,7 +1354,7 @@ int process_iptv_multicast(const unsigned char *p, int size, const char *mac) { } } - LOG_MSG(debug, ZLOG_MOD_OPENDHCPD, "Found IPTV %s\n", mac); + LOG_MOD(debug, ZLOG_MOD_OPENDHCPD, "Found IPTV %s\n", mac); return 0; } @@ -1399,12 +1399,12 @@ void opendhcp_add_mac_filter() { if (sdslen(add) > 0) { sdsrange(add, 0, -3); - LOG_MSG(debug, ZLOG_MOD_OPENDHCPD, "Add MAC [%s] for black list\n", add); + LOG_MOD(debug, ZLOG_MOD_OPENDHCPD, "Add MAC [%s] for black list\n", add); } if (sdslen(err) > 0) { sdsrange(err, 0, -2); - LOG_MSG(debug, ZLOG_MOD_OPENDHCPD, "Add MAC [%s] for black list error\n", err); + LOG_MOD(debug, ZLOG_MOD_OPENDHCPD, "Add MAC [%s] for black list error\n", err); } sdsfree(add); diff --git a/srcs/pppoe/vcpe_pppoe.c b/srcs/pppoe/vcpe_pppoe.c index 85ddaad..7a7536b 100644 --- a/srcs/pppoe/vcpe_pppoe.c +++ b/srcs/pppoe/vcpe_pppoe.c @@ -59,7 +59,7 @@ static void pppLinkStatusCallback(ppp_pcb *pcb, int errCode, void *ctx) { switch (errCode) { case PPPERR_NONE: { /* No error. */ pCache = (PPPPOE_CACHE)malloc(sizeof(PPPOE_CACHE)); - LOG_MSG(info, ZLOG_MOD_PPPOE, ("<%p> PPPoE user(%05d:%s) connect server succeeded[%08X], Session: %04X\n", + LOG_MOD(info, ZLOG_MOD_PPPOE, ("<%p> PPPoE user(%05d:%s) connect server succeeded[%08X], Session: %04X\n", pcb, pUser->userid, pUser->user_info.pppoe_user, @@ -78,16 +78,16 @@ static void pppLinkStatusCallback(ppp_pcb *pcb, int errCode, void *ctx) { pUser->user_info.mac_addr[3], pUser->user_info.mac_addr[4], pUser->user_info.mac_addr[5]); - LOG_MSG(info, ZLOG_MOD_PPPOE, (" our_ipaddr = %s\n", pUser->session.data.clientIp); - LOG_MSG(info, ZLOG_MOD_PPPOE, (" his_ipaddr = %s\n", pUser->session.data.clientGw); - LOG_MSG(info, ZLOG_MOD_PPPOE, (" netmask = %s\n", pUser->session.data.clientMask); + LOG_MOD(info, ZLOG_MOD_PPPOE, (" our_ipaddr = %s\n", pUser->session.data.clientIp); + LOG_MOD(info, ZLOG_MOD_PPPOE, (" his_ipaddr = %s\n", pUser->session.data.clientGw); + LOG_MOD(info, ZLOG_MOD_PPPOE, (" netmask = %s\n", pUser->session.data.clientMask); #endif /* LWIP_IPV4 */ #if LWIP_DNS - LOG_MSG(info, ZLOG_MOD_PPPOE, (" dns1 = %s\n", ipaddr_ntoa(dns_getserver(0))); - LOG_MSG(info, ZLOG_MOD_PPPOE, (" dns2 = %s\n", ipaddr_ntoa(dns_getserver(1))); + LOG_MOD(info, ZLOG_MOD_PPPOE, (" dns1 = %s\n", ipaddr_ntoa(dns_getserver(0))); + LOG_MOD(info, ZLOG_MOD_PPPOE, (" dns2 = %s\n", ipaddr_ntoa(dns_getserver(1))); #endif /* LWIP_DNS */ #if PPP_IPV6_SUPPORT - LOG_MSG(info, ZLOG_MOD_PPPOE, (" our6_ipaddr = %s\n", ip6addr_ntoa(netif_ip6_addr(pppif, 0))); + LOG_MOD(info, ZLOG_MOD_PPPOE, (" our6_ipaddr = %s\n", ip6addr_ntoa(netif_ip6_addr(pppif, 0))); #endif /* PPP_IPV6_SUPPORT */ if (pCache) { @@ -103,7 +103,7 @@ static void pppLinkStatusCallback(ppp_pcb *pcb, int errCode, void *ctx) { case PPPERR_PARAM: case PPPERR_AUTHFAIL: case PPPERR_PROTOCOL: - LOG_MSG(error, ZLOG_MOD_PPPOE, ("<%p> pppLinkStatusCallback: %s(%d)", + LOG_MOD(error, ZLOG_MOD_PPPOE, ("<%p> pppLinkStatusCallback: %s(%d)", pcb, g_pppoeErr[errCode].errmsg, g_pppoeErr[errCode].errid); @@ -127,7 +127,7 @@ static void pppLinkStatusCallback(ppp_pcb *pcb, int errCode, void *ctx) { } break; case PPPERR_USER: - LOG_MSG(info, ZLOG_MOD_PPPOE, ("User(%05d:%s) disconnect\n", pUser->userid, pUser->user_info.pppoe_user); + LOG_MOD(info, ZLOG_MOD_PPPOE, ("User(%05d:%s) disconnect\n", pUser->userid, pUser->user_info.pppoe_user); pCache = (PPPPOE_CACHE)malloc(sizeof(PPPOE_CACHE)); if (pCache) { @@ -148,7 +148,7 @@ static void pppLinkStatusCallback(ppp_pcb *pcb, int errCode, void *ctx) { case PPPERR_IDLETIMEOUT: case PPPERR_CONNECTTIME: case PPPERR_LOOPBACK: - LOG_MSG(error, ZLOG_MOD_PPPOE, ("<%p> pppLinkStatusCallback: %s(%d)\n", + LOG_MOD(error, ZLOG_MOD_PPPOE, ("<%p> pppLinkStatusCallback: %s(%d)\n", pcb, g_pppoeErr[errCode].errmsg, g_pppoeErr[errCode].errid); @@ -189,13 +189,13 @@ _Noreturn void sessionCalcCb(void *UNUSED(pArg)) { switch (pSession->status) { case STATUS_TASK_INIT: if (pppoe_session_create(pUser) == ERR_SUCCESS) { - LOG_MSG(debug, ZLOG_MOD_PPPOE, ("User(%05d:%s) init pppoe session\n", pUser->userid, pUser->user_info.pppoe_user); + LOG_MOD(debug, ZLOG_MOD_PPPOE, ("User(%05d:%s) init pppoe session\n", pUser->userid, pUser->user_info.pppoe_user); pSession->status = STATUS_TASK_DIAL; } break; case STATUS_TASK_DIAL: if (pUser->session.retry.timeout == 0) { - LOG_MSG(debug, ZLOG_MOD_PPPOE, ("User(%05d:%s) connect PPPoE server\n", pUser->userid, pUser->user_info.pppoe_user); + LOG_MOD(debug, ZLOG_MOD_PPPOE, ("User(%05d:%s) connect PPPoE server\n", pUser->userid, pUser->user_info.pppoe_user); pppapi_connect(pSession->ppp, 0); pUser->session.retry.timeout = time(NULL) + PPPOE_MAX_TIMEOUT; } else if (time(NULL) > pUser->session.retry.timeout) { @@ -204,14 +204,14 @@ _Noreturn void sessionCalcCb(void *UNUSED(pArg)) { break; case STATUS_TASK_ERROR: if (pUser->session.retry.timeout == 0) { - LOG_MSG(error, ZLOG_MOD_PPPOE, ("User(%05d:%s) PPPoE dial error Invalid parameter\n", + LOG_MOD(error, ZLOG_MOD_PPPOE, ("User(%05d:%s) PPPoE dial error Invalid parameter\n", pUser->userid, pUser->user_info.pppoe_user); // 10秒后尝试重新拨号 pUser->session.retry.timeout = time(NULL) + (PPPOE_MAX_TIMEOUT / 2); pUser->session.retry.count = 0; } else if (time(NULL) > pUser->session.retry.timeout) { - LOG_MSG(warn, ZLOG_MOD_PPPOE, ("User(%05d:%s) retry dial %u times\n", + LOG_MOD(warn, ZLOG_MOD_PPPOE, ("User(%05d:%s) retry dial %u times\n", pUser->userid, pUser->user_info.pppoe_user, pUser->session.retry.count); @@ -224,14 +224,14 @@ _Noreturn void sessionCalcCb(void *UNUSED(pArg)) { break; case STATUS_TASK_DISCONNECTED: - LOG_MSG(error, ZLOG_MOD_PPPOE, ("User %s disconnect, auto reconnect\n", pUser->user_info.pppoe_user); + LOG_MOD(error, ZLOG_MOD_PPPOE, ("User %s disconnect, auto reconnect\n", pUser->user_info.pppoe_user); // 自动重新拨号 pSession->status = STATUS_TASK_DIAL; break; case STATUS_TASK_DELETE: if (pUser->session.retry.timeout == 0) { - LOG_MSG(debug, ZLOG_MOD_PPPOE, ("User(%05d:%s) PPPoE deleted\n", pUser->userid, pUser->user_info.pppoe_user); + LOG_MOD(debug, ZLOG_MOD_PPPOE, ("User(%05d:%s) PPPoE deleted\n", pUser->userid, pUser->user_info.pppoe_user); pppapi_close(pUser->session.ppp, 0); pUser->session.retry.timeout = time(NULL); pppapi_free(pUser->session.ppp); @@ -244,7 +244,7 @@ _Noreturn void sessionCalcCb(void *UNUSED(pArg)) { if (pUser->session.retry.timeout == 0) { pUser->session.retry.timeout = time(NULL) + 30; } else if (time(NULL) > pUser->session.retry.timeout) { - LOG_MSG(debug, ZLOG_MOD_PPPOE, ("User(%05d:%s) PPPoE disconnected\n", pUser->userid, pUser->user_info.pppoe_user); + LOG_MOD(debug, ZLOG_MOD_PPPOE, ("User(%05d:%s) PPPoE disconnected\n", pUser->userid, pUser->user_info.pppoe_user); pSession->status = STATUS_TASK_DELETE; pppapi_close(pUser->session.ppp, 0); pUser->session.retry.timeout = 0; @@ -336,9 +336,9 @@ int pppoe_session_init() { g_rawSocketIf = bind_pcap_if(config_get_vxlan_nic_name(), config_get_vxlan_pkg_filter(), cfg_get_support_vxlan()); if (g_rawSocketIf) { - LOG_MSG(info, ZLOG_MOD_PPPOE, ("Create hardware netif: <%p>\n", (void *)g_rawSocketIf); + LOG_MOD(info, ZLOG_MOD_PPPOE, ("Create hardware netif: <%p>\n", (void *)g_rawSocketIf); } else { - LOG_MSG(info, ZLOG_MOD_PPPOE, ("Create hardware error: <%p>\n", (void *)g_rawSocketIf); + LOG_MOD(info, ZLOG_MOD_PPPOE, ("Create hardware error: <%p>\n", (void *)g_rawSocketIf); } // 启动Session状态机线程 @@ -353,14 +353,14 @@ int pppoe_session_create(PUSER_INFO_CONTEXT pUser) { struct netif *ppp_netif = (struct netif *)malloc(sizeof(struct netif)); if (ppp_netif == NULL) { - LOG_MSG(error, ZLOG_MOD_PPPOE, ("Malloc %lu bytes memory error\n", sizeof(struct netif)); + LOG_MOD(error, ZLOG_MOD_PPPOE, ("Malloc %lu bytes memory error\n", sizeof(struct netif)); return -ERR_MALLOC_MEMORY; } netif = create_pppoe_if(pUser); if (netif == NULL) { - LOG_MSG(error, ZLOG_MOD_PPPOE, ("Create PPPoE netif error: %u\n", pUser->userid); + LOG_MOD(error, ZLOG_MOD_PPPOE, ("Create PPPoE netif error: %u\n", pUser->userid); free((void *)ppp_netif); return -ERR_CREATE_PPPOE_NETIF; } @@ -371,7 +371,7 @@ int pppoe_session_create(PUSER_INFO_CONTEXT pUser) { ppp = pppapi_pppoe_create(pUser->session.pppif, pUser->session.nicif, NULL, NULL, pppLinkStatusCallback, pUser); if (ppp == NULL) { - LOG_MSG(error, ZLOG_MOD_PPPOE, ("Create PPPoE session error: %u\n", pUser->userid); + LOG_MOD(error, ZLOG_MOD_PPPOE, ("Create PPPoE session error: %u\n", pUser->userid); netif_remove(netif); free((void *)ppp_netif); return -ERR_CREATE_PPP_SESSION; @@ -381,7 +381,7 @@ int pppoe_session_create(PUSER_INFO_CONTEXT pUser) { ppp_set_auth(ppp, PPPAUTHTYPE_ANY, pUser->user_info.pppoe_user, pUser->user_info.pppoe_passwd); - LOG_MSG(debug, ZLOG_MOD_PPPOE, ("Create PPPoE netif %p: %u(%c%c:%u, %c%c:%u)\n", + LOG_MOD(debug, ZLOG_MOD_PPPOE, ("Create PPPoE netif %p: %u(%c%c:%u, %c%c:%u)\n", ppp, pUser->userid, ppp_netif->name[0], diff --git a/srcs/user/user_info.c b/srcs/user/user_info.c index 96ad4c1..1727b85 100644 --- a/srcs/user/user_info.c +++ b/srcs/user/user_info.c @@ -71,7 +71,7 @@ int user_info_add(unsigned int userid, PUSER_PARAMS pInfo) { HASH_ADD(hh_mac, g_pUserByMacList, mac_addr, 6, pList); uv_rwlock_wrunlock(&g_userLock); - LOG_MSG(debug, + LOG_MOD(debug, ZLOG_MOD_USER, "Add user: id = %u, vni = %u, q1 = %u, q2 = %u, ppp_user = %s, mac = %02X:%02X:%02X:%02X:%02X:%02X\n", userid, diff --git a/srcs/vcpe_main.c b/srcs/vcpe_main.c index d7b6cff..f74282d 100644 --- a/srcs/vcpe_main.c +++ b/srcs/vcpe_main.c @@ -65,11 +65,11 @@ static void on_http_response_cb(void *pData, int iFinished, void *pUserData) { if (iFinished == 0) { - LOG_MSG(debug, ZLOG_MOD_MAIN, "Request(%s): [%s] Response: [%u] OK:\n", pTaskUuid, pReqUrl, size); + LOG_MOD(debug, ZLOG_MOD_MAIN, "Request(%s): [%s] Response: [%u] OK:\n", pTaskUuid, pReqUrl, size); } else if (iFinished == 1) { - LOG_MSG(error, ZLOG_MOD_MAIN, "Request(%s): [%s] Response: [%u] Error\n", pTaskUuid, pReqUrl, size); + LOG_MOD(error, ZLOG_MOD_MAIN, "Request(%s): [%s] Response: [%u] Error\n", pTaskUuid, pReqUrl, size); } else { - LOG_MSG(error, ZLOG_MOD_MAIN, "Download Error Code: %d\n", iFinished); + LOG_MOD(error, ZLOG_MOD_MAIN, "Download Error Code: %d\n", iFinished); } free(pUserData);