调整限制日志输出逻辑,通过调用函数位置做单独的限制输出速率,不再通过handle做整体限制
This commit is contained in:
@@ -14,10 +14,21 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#define RLOG_LV_DEBUG 10
|
||||
#define RLOG_LV_INFO 20
|
||||
#define RLOG_LV_FATAL 30
|
||||
|
||||
typedef struct log_ratelimit_s
|
||||
{
|
||||
int interval;
|
||||
int burst;
|
||||
int printed;
|
||||
int missed;
|
||||
long begin;
|
||||
pthread_mutex_t mutex;
|
||||
}log_ratelimit_t;
|
||||
|
||||
int MESA_handle_runtime_log_creation(const char *conf_path);
|
||||
int MESA_handle_runtime_log_reconstruction(const char *conf_path);
|
||||
@@ -27,6 +38,15 @@ void MESA_handle_runtime_log_destruction();
|
||||
MESA_handle_runtime_log((handle), (lv), (mod), "file %s, line %d, " fmt, \
|
||||
__FILE__, __LINE__, ##args)
|
||||
|
||||
#define MESA_HANDLE_RUNTIME_LOG_RATELIMIT(handle, lv, mod, fmt, args...) \
|
||||
({ \
|
||||
static log_ratelimit_t _rs = { \
|
||||
.mutex = PTHREAD_MUTEX_INITIALIZER, \
|
||||
}; \
|
||||
if (MESA_runtime_log_ratelimit((handle), (&_rs), (lv), (mod), (__func__))) \
|
||||
MESA_handle_runtime_log((handle), (lv), (mod), fmt, ##args); \
|
||||
})
|
||||
|
||||
/*
|
||||
* name: MESA_create_runtime_log_handle
|
||||
* functionality: get runtime_log handle;
|
||||
@@ -64,7 +84,7 @@ void MESA_handle_runtime_log(void *handle, int level, const char *module, const
|
||||
void MESA_destroy_runtime_log_handle(void *handle);
|
||||
|
||||
/*
|
||||
* name: MESA_set_handle_ratelimit
|
||||
* name: MESA_set_runtime_log_handle_ratelimit
|
||||
* functionality: set not more than @burst in every @interval when appends log message
|
||||
* params:
|
||||
* handle: runtime log handle which is going to be released;
|
||||
|
||||
Reference in New Issue
Block a user