From 3db4f4ed6dec55316e7167eaddd9ddf0af875185 Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Fri, 8 Mar 2019 14:13:32 +0200 Subject: logging.c/h: aggressively remove sprintfs() Try to reduce the number of sprintf() and string copies until we finally log a log line. Specifically, do not sprintf separately the timestr string and do not sprintf/strcpy the appmsgstr separately - just stick it with the header. Hoping I did not leak anything or changed the log line formatting. Also, allocate 4K (GF_LOG_BACKTRACE_SIZE) of memory dynamically for trace output - only if trace was actually requested (previously, it was unconditionally) In addition, some minor code formatting (unrelated to the above). updates: bz#1193929 Signed-off-by: Yaniv Kaul Change-Id: Id2ccc85f9213a2b1c6eaa4a2f58ce043eac1824f --- libglusterfs/src/glusterfs/logging.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libglusterfs/src/glusterfs/logging.h') diff --git a/libglusterfs/src/glusterfs/logging.h b/libglusterfs/src/glusterfs/logging.h index 3655b1d11b..31ecbfcbdb 100644 --- a/libglusterfs/src/glusterfs/logging.h +++ b/libglusterfs/src/glusterfs/logging.h @@ -98,11 +98,9 @@ typedef enum { typedef struct gf_log_handle_ { pthread_mutex_t logfile_mutex; - uint8_t logrotate; - uint8_t cmd_history_logrotate; gf_loglevel_t loglevel; - int gf_log_syslog; gf_loglevel_t sys_log_level; + int gf_log_syslog; char *filename; FILE *logfile; FILE *gf_log_logfile; @@ -113,12 +111,14 @@ typedef struct gf_log_handle_ { char *ident; int log_control_file_found; struct list_head lru_queue; - uint32_t lru_size; - uint32_t lru_cur_size; - uint32_t timeout; pthread_mutex_t log_buf_lock; struct _gf_timer *log_flush_timer; int localtime; + uint32_t lru_size; + uint32_t lru_cur_size; + uint32_t timeout; + uint8_t logrotate; + uint8_t cmd_history_logrotate; } gf_log_handle_t; typedef struct log_buf_ { -- cgit