diff options
| author | N Balachandran <nbalacha@redhat.com> | 2017-07-24 17:48:47 +0530 | 
|---|---|---|
| committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2017-08-03 12:04:50 +0000 | 
| commit | 498164fa45309bd314ff2fcc282b140edf72bc22 (patch) | |
| tree | 352f8e6c7dc924627010e555c63941143ff84e1f /libglusterfs/src/common-utils.h | |
| parent | 10da7c37b30f7995bf65dbb4babbbb5216bcc925 (diff) | |
logging: localtime logging, cmdline, volume set option
Despite the fact that appliances generally use UTC, some
users really want log entries in localtime.
fixes gluster/glusterfs#272
feature page: https://review.gluster.org/17807
Backport from master https://review.gluster.org/#/c/16911/
Change-Id: I5fbf2c3eedd9eb128fb3f851dd67b2f4081c8bba
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Reviewed-on: https://review.gluster.org/17928
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Diffstat (limited to 'libglusterfs/src/common-utils.h')
| -rw-r--r-- | libglusterfs/src/common-utils.h | 7 | 
1 files changed, 5 insertions, 2 deletions
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index 1d7f09dbc82..022a2a70ff0 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -687,12 +687,15 @@ gf_time_fmt (char *dst, size_t sz_dst, time_t utime, unsigned int fmt)          static gf_timefmts timefmt_last = (gf_timefmts) - 1;          static const char **fmts;          static const char **zeros; -        struct tm tm; +        struct tm tm, *res; +        int localtime = 0;          if (timefmt_last == (gf_timefmts) - 1)                  _gf_timestuff (&timefmt_last, &fmts, &zeros);          if (timefmt_last < fmt) fmt = gf_timefmt_default; -        if (utime && gmtime_r (&utime, &tm) != NULL) { +        localtime = gf_log_get_localtime (); +        res = localtime ? localtime_r (&utime, &tm) : gmtime_r (&utime, &tm); +        if (utime && res != NULL) {                  strftime (dst, sz_dst, fmts[fmt], &tm);          } else {                  strncpy (dst, "N/A", sz_dst);  | 
