From 2594dd69bd2a1e23e915d6ed690a9cd0e5993a04 Mon Sep 17 00:00:00 2001 From: Gabe Levi Date: Wed, 14 Mar 2018 13:22:08 -0700 Subject: [PATCH] Add milliseconds to Hh_logger timestamps Reviewed By: samwgoldman Differential Revision: D7272225 fbshipit-source-id: fecd60359170e803a34a099aa111bec3840022d2 --- hphp/hack/src/utils/hh_logger.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hphp/hack/src/utils/hh_logger.ml b/hphp/hack/src/utils/hh_logger.ml index 46bc1fbc074..7a4ae4f88d0 100644 --- a/hphp/hack/src/utils/hh_logger.ml +++ b/hphp/hack/src/utils/hh_logger.ml @@ -11,9 +11,10 @@ let timestamp_string () = let open Unix in let tm = localtime (time ()) in + let ms = int_of_float (gettimeofday () *. 1000.) mod 1000 in let year = tm.tm_year + 1900 in - Printf.sprintf "[%d-%02d-%02d %02d:%02d:%02d]" - year (tm.tm_mon + 1) tm.tm_mday tm.tm_hour tm.tm_min tm.tm_sec + Printf.sprintf "[%d-%02d-%02d %02d:%02d:%02d.%03d]" + year (tm.tm_mon + 1) tm.tm_mday tm.tm_hour tm.tm_min tm.tm_sec ms (* We might want to log to both stderr and a file. Shelling out to tee isn't cross-platform. * We could dup2 stderr to a pipe and have a child process write to both original stderr and the -- 2.11.4.GIT