diff options
Diffstat (limited to 'libglusterfs/src/common-utils.c')
| -rw-r--r-- | libglusterfs/src/common-utils.c | 31 | 
1 files changed, 25 insertions, 6 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 3e6543be75c..dbcee77be80 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -342,10 +342,8 @@ void  gf_print_trace (int32_t signum)  {          extern FILE *gf_log_logfile; -        struct tm   *tm = NULL;          char         msg[1024] = {0,}; -        char         timestr[256] = {0,}; -        time_t       utime = 0; +        char         timestr[64] = {0,};          int          ret = 0;          int          fd = 0; @@ -394,9 +392,7 @@ gf_print_trace (int32_t signum)          {                  /* Dump the timestamp of the crash too, so the previous logs                     can be related */ -                utime = time (NULL); -                tm    = localtime (&utime); -                strftime (timestr, 256, "%Y-%m-%d %H:%M:%S\n", tm); +                gf_time_fmt (timestr, sizeof timestr, time (NULL), gf_timefmt_FT);                  ret = write (fd, "time of crash: ", 15);                  if (ret < 0)                          goto out; @@ -2038,3 +2034,26 @@ gf_strip_whitespace (char *str, int len)          GF_FREE (new_str);          return new_len;  } + +static const char *__gf_timefmts[] = { +        "%F %T", +        "%Y/%m/%d-%T", +        "%b %d %T", +        "%F %H%M%S" +}; + +static const char *__gf_zerotimes[] = { +        "0000-00-00 00:00:00", +        "0000/00/00-00:00:00", +        "xxx 00 00:00:00", +        "0000-00-00 000000" +}; + +void +_gf_timestuff (gf_timefmts *fmt, const char ***fmts, const char ***zeros) +{ +        *fmt = gf_timefmt_last; +        *fmts = __gf_timefmts; +        *zeros = __gf_zerotimes; +} +  | 
