summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/logging.c
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-05-20 07:24:28 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-05-21 00:32:15 -0700
commit3047188b314b3d2a4788451d2b7ab633b8d127ff (patch)
tree9567d78949164973cf0db42f15f65e024de7d342 /libglusterfs/src/logging.c
parent719354ddbd6b68f2b1df6d03e70683a65daf1eb0 (diff)
libglusterfs: Use usecond resolution for logging
Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 936 (Provide microsecond timestamp in logfile) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=936
Diffstat (limited to 'libglusterfs/src/logging.c')
-rw-r--r--libglusterfs/src/logging.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index 7fbcacb4e44..e298b327e51 100644
--- a/libglusterfs/src/logging.c
+++ b/libglusterfs/src/logging.c
@@ -153,9 +153,9 @@ _gf_log (const char *domain, const char *file, const char *function, int line,
const char *basename = NULL;
FILE *new_logfile = NULL;
va_list ap;
- time_t utime = 0;
struct tm *tm = NULL;
char timestr[256];
+ struct timeval tv = {0,};
char *str1 = NULL;
char *str2 = NULL;
@@ -200,8 +200,11 @@ _gf_log (const char *domain, const char *file, const char *function, int line,
}
log:
- utime = time (NULL);
- tm = localtime (&utime);
+ ret = gettimeofday (&tv, NULL);
+ if (-1 == ret)
+ goto out;
+
+ tm = localtime (&tv.tv_sec);
if (level > loglevel) {
goto out;
@@ -212,6 +215,8 @@ log:
va_start (ap, fmt);
strftime (timestr, 256, "%Y-%m-%d %H:%M:%S", tm);
+ snprintf (timestr + strlen (timestr), 256 - strlen (timestr),
+ ".%ld", tv.tv_usec);
basename = strrchr (file, '/');
if (basename)