diff options
| author | yangwei <[email protected]> | 2023-05-30 18:59:08 +0800 |
|---|---|---|
| committer | yangwei <[email protected]> | 2023-05-31 11:26:49 +0800 |
| commit | 7fa29b1a00b1d33c85f73686260d674b66ffb9e9 (patch) | |
| tree | db6217ddd466f1e1870899a8622ab881583b6f99 /src | |
| parent | 8680c2f4f5639dbdabfa383b1d0819aabd7cc652 (diff) | |
🎈 perf(MESA_handle_runtime_log): 内部增加判断level的级别,提供宏展开示例
Diffstat (limited to 'src')
| -rw-r--r-- | src/MESA_handle_logger.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/MESA_handle_logger.c b/src/MESA_handle_logger.c index 93da94c..d9b8274 100644 --- a/src/MESA_handle_logger.c +++ b/src/MESA_handle_logger.c @@ -163,7 +163,7 @@ static void snapshot_handle_info(const char *handle_name, const char *log_path, return; } -struct log_handle_t *MESA_create_runtime_log_handle(const char *file_path, int level) +void *MESA_create_runtime_log_handle(const char *file_path, int level) { if(file_path == NULL) return NULL; @@ -202,7 +202,7 @@ struct log_handle_t *MESA_create_runtime_log_handle(const char *file_path, int l return (void *)handle; } -void MESA_destroy_runtime_log_handle(struct log_handle_t *handle) +void MESA_destroy_runtime_log_handle(void *handle) { if(handle != NULL) { @@ -214,24 +214,28 @@ void MESA_destroy_runtime_log_handle(struct log_handle_t *handle) } -int MESA_handle_runtime_log_level_enabled(struct log_handle_t *handle, const int level) +int MESA_handle_runtime_log_level_enabled(void *v_handle, const int level) { - if(handle == NULL || handle->runtime_log_file == NULL)return; + struct log_handle_t *handle = (struct log_handle_t *)v_handle; + if(handle == NULL || handle->runtime_log_file == NULL)return; if(handle->zc == NULL) return; return zlog_level_enabled(handle->zc, level); } -void MESA_handle_runtime_log(struct log_handle_t *handle, int level, const char *module, const char *fmt, ...) +void MESA_handle_runtime_log(void *v_handle, int level, const char *module, const char *fmt, ...) { - + struct log_handle_t *handle = (struct log_handle_t *)handle; if(handle == NULL || handle->runtime_log_file == NULL)return; if(handle->zc == NULL)return; - va_list ap; - va_start(ap, fmt); - vzlog(handle->zc, handle->runtime_log_file, strlen(handle->runtime_log_file), module, strlen(module), __LINE__, level, fmt, ap); - va_end(ap); + if (zlog_level_enabled(handle->zc, level)) + { + va_list ap; + va_start(ap, fmt); + vzlog(handle->zc, handle->runtime_log_file, strlen(handle->runtime_log_file), module, strlen(module), __LINE__, level, fmt, ap); + va_end(ap); + } return ; } |
