diff options
author | Yaniv Kaul <ykaul@redhat.com> | 2019-03-08 14:13:32 +0200 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2019-04-25 04:13:31 +0000 |
commit | 3db4f4ed6dec55316e7167eaddd9ddf0af875185 (patch) | |
tree | 2a2381befb39488755d207dfbd848c176524eda7 /libglusterfs/src/glusterfs/logging.h | |
parent | 1ccc62d11287e8ffd091123517f7988a4e7f1935 (diff) | |
download | glusterfs-3db4f4ed6dec55316e7167eaddd9ddf0af875185.tar.gz glusterfs-3db4f4ed6dec55316e7167eaddd9ddf0af875185.tar.xz glusterfs-3db4f4ed6dec55316e7167eaddd9ddf0af875185.zip |
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 <ykaul@redhat.com>
Change-Id: Id2ccc85f9213a2b1c6eaa4a2f58ce043eac1824f
Diffstat (limited to 'libglusterfs/src/glusterfs/logging.h')
-rw-r--r-- | libglusterfs/src/glusterfs/logging.h | 12 |
1 files changed, 6 insertions, 6 deletions
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_ { |