summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2014-06-16 12:29:03 -0400
committerVijay Bellur <vbellur@redhat.com>2014-11-20 06:59:16 -0800
commit9797bd197d48ca17a124c245295937ac3d48ab58 (patch)
tree174fe233d2f1e34e5ce16818e02f68c4f030c4b8 /libglusterfs
parent27c2be4af6f2dc0a18410e17862bb5d3a07231f3 (diff)
core: use gf_time_fmt() instead of localtime()+strftime()
gf_time_fmt() has existed since 3.3; it provides consistent timestamps (i.e. UTC times) throughout the implementation. (BTW, the other name for UTC is GMT.) N.B. many (all?) commercial storage solutions use UTC time for logging. This makes for easier debugging across geographically distributed systems. Also adding a "%s" fmt for portably printing time as simple numeric value on systems regardless of whether 32-bit or 64-bit time_t. Plus a minor tweak to return a ptr to the dest-string to allow gf_time_fmt() to be passed as a param in a *printf(). Someday we should pick the "one true" timestamp format and revise all calls to gf_time_fmt() to use it instead of the five or six different formats. Change-Id: I78202ae14b7246fa424efeea56bf2463e14abfb0 BUG: 1109917 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com> Reviewed-on: http://review.gluster.org/8085 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/common-utils.c2
-rw-r--r--libglusterfs/src/common-utils.h6
2 files changed, 6 insertions, 2 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 1318c4d49a6..b1afa082844 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -2470,6 +2470,7 @@ static const char *__gf_timefmts[] = {
"%b %d %T",
"%F %H%M%S",
"%Y-%m-%d-%T",
+ "%s",
};
static const char *__gf_zerotimes[] = {
@@ -2478,6 +2479,7 @@ static const char *__gf_zerotimes[] = {
"xxx 00 00:00:00",
"0000-00-00 000000",
"0000-00-00-00:00:00",
+ "0",
};
void
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index d2bc42b9662..2493ba10816 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -486,13 +486,14 @@ typedef enum {
gf_timefmt_default = 0,
gf_timefmt_FT = 0, /* YYYY-MM-DD hh:mm:ss */
gf_timefmt_Ymd_T, /* YYYY/MM-DD-hh:mm:ss */
- gf_timefmt_bdT, /* ddd DD hh:mm:ss */
+ gf_timefmt_bdT, /* MMM DD hh:mm:ss */
gf_timefmt_F_HMS, /* YYYY-MM-DD hhmmss */
gf_timefmt_dirent,
+ gf_timefmt_s,
gf_timefmt_last
} gf_timefmts;
-static inline void
+static inline char *
gf_time_fmt (char *dst, size_t sz_dst, time_t utime, unsigned int fmt)
{
extern void _gf_timestuff (gf_timefmts *, const char ***, const char ***);
@@ -509,6 +510,7 @@ gf_time_fmt (char *dst, size_t sz_dst, time_t utime, unsigned int fmt)
} else {
strncpy (dst, "N/A", sz_dst);
}
+ return dst;
}
int