From dc43f8254a43cceecb88355870a76a1322a7ce87 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Mon, 21 Sep 2020 22:27:16 +0800 Subject: [PATCH] remove useless logInfo --- src/fast_allocator.c | 13 ++++++++----- src/fast_mblock.c | 5 +++-- src/logger.h | 5 +++++ src/shared_buffer.h | 4 +++- src/thread_pool.c | 4 ++-- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/fast_allocator.c b/src/fast_allocator.c index 3a1229b..2933bc6 100644 --- a/src/fast_allocator.c +++ b/src/fast_allocator.c @@ -25,7 +25,8 @@ static struct fast_allocator_info malloc_allocator; (allocator)->pooled = _pooled; \ acontext->allocator_array.allocators[ \ acontext->allocator_array.count++] = allocator; \ - /* logInfo("count: %d, magic_number: %d", acontext->allocator_array.count, (allocator)->magic_number); */\ + /* logInfo("count: %d, magic_number: %d", acontext->allocator_array.count, \ + (allocator)->magic_number); */ \ } while (0) @@ -388,8 +389,10 @@ int fast_allocator_retry_reclaim(struct fast_allocator_context *acontext, acontext->allocator_array.last_reclaim_time = get_current_time(); malloc_bytes = acontext->allocator_array.malloc_bytes; - logInfo("malloc_bytes: %"PRId64", ratio: %f", malloc_bytes, (double)acontext->alloc_bytes / - (double)malloc_bytes); + /* + logInfo("malloc_bytes: %"PRId64", ratio: %f", malloc_bytes, + (double)acontext->alloc_bytes / (double)malloc_bytes); + */ if (malloc_bytes == 0 || (double)acontext->alloc_bytes / (double)malloc_bytes >= acontext->allocator_array.expect_usage_ratio) @@ -402,7 +405,7 @@ int fast_allocator_retry_reclaim(struct fast_allocator_context *acontext, if (fast_mblock_reclaim(&acontext->allocator_array. allocators[i]->mblock, 0, &reclaim_count, NULL) == 0) { - logInfo("reclaim_count: %d", reclaim_count); + //logInfo("reclaim_count: %d", reclaim_count); *total_reclaim_bytes += reclaim_count * acontext->allocator_array.allocators[i]-> mblock.info.trunk_size; @@ -440,7 +443,7 @@ void *fast_allocator_alloc(struct fast_allocator_context *acontext, { return NULL; } - logInfo("reclaimed bytes: %"PRId64, total_reclaim_bytes); + //logInfo("reclaimed bytes: %"PRId64, total_reclaim_bytes); if (total_reclaim_bytes < allocator_info->mblock.info.trunk_size) { return NULL; diff --git a/src/fast_mblock.c b/src/fast_mblock.c index 081256f..08c1bae 100644 --- a/src/fast_mblock.c +++ b/src/fast_mblock.c @@ -116,8 +116,9 @@ static void delete_from_mblock_list(struct fast_mblock_man *mblock) pStat->trunk_total_count += current->info.trunk_total_count; \ pStat->trunk_used_count += current->info.trunk_used_count; \ pStat->instance_count += current->info.instance_count; \ - /* logInfo("name: %s, element_size: %d, total_count: %d, used_count: %d", */ \ - /* pStat->name, pStat->element_size, pStat->element_total_count, pStat->element_used_count); */\ + /* logInfo("name: %s, element_size: %d, total_count: %d, " \ + "used_count: %d", pStat->name, pStat->element_size, \ + pStat->element_total_count, pStat->element_used_count); */ \ } while (0) int fast_mblock_manager_stat(struct fast_mblock_info *stats, diff --git a/src/logger.h b/src/logger.h index b3821e9..eb30718 100644 --- a/src/logger.h +++ b/src/logger.h @@ -29,11 +29,16 @@ extern "C" { #define LOG_COMPRESS_FLAGS_ENABLED 1 #define LOG_COMPRESS_FLAGS_NEW_THREAD 2 +#define LOG_NOTHING (LOG_DEBUG + 10) + struct log_context; //log header line callback typedef void (*LogHeaderCallback)(struct log_context *pContext); +#define FC_LOG_BY_LEVEL(level) \ + (level <= g_log_context.log_level) + typedef struct log_context { /* log level value please see: sys/syslog.h diff --git a/src/shared_buffer.h b/src/shared_buffer.h index 3445393..4498aed 100644 --- a/src/shared_buffer.h +++ b/src/shared_buffer.h @@ -60,8 +60,10 @@ static inline void shared_buffer_hold(SharedBuffer *buffer) static inline void shared_buffer_release(SharedBuffer *buffer) { if (__sync_sub_and_fetch(&buffer->reffer_count, 1) == 0) { - logInfo("file: "__FILE__", line: %d, " + /* + logDebug("file: "__FILE__", line: %d, " "free shared buffer: %p", __LINE__, buffer); + */ fast_mblock_free_object(&buffer->ctx->allocator, buffer); } } diff --git a/src/thread_pool.c b/src/thread_pool.c index 64a0194..967545d 100644 --- a/src/thread_pool.c +++ b/src/thread_pool.c @@ -31,7 +31,7 @@ static void *thread_entrance(void *arg) PTHREAD_MUTEX_LOCK(&pool->lock); pool->thread_counts.running++; - logInfo("thread pool: %s, index: %d start, running count: %d", + logDebug("thread pool: %s, index: %d start, running count: %d", pool->name, thread->index, pool->thread_counts.running); PTHREAD_MUTEX_UNLOCK(&pool->lock); @@ -100,7 +100,7 @@ static void *thread_entrance(void *arg) } PTHREAD_MUTEX_LOCK(&pool->lock); - logInfo("thread pool: %s, index: %d exit, running count: %d", + logDebug("thread pool: %s, index: %d exit, running count: %d", pool->name, thread->index, pool->thread_counts.running); PTHREAD_MUTEX_UNLOCK(&pool->lock);