Fix GlogFormatterTest on Windows
authorChristopher Dykes <cdykes@fb.com>
Fri, 23 Jun 2017 02:55:36 +0000 (19:55 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 23 Jun 2017 03:08:43 +0000 (20:08 -0700)
Summary:
It was missing a portability header needed for `setenv`, and was assuming that the `system_clock` was represented as nanoseconds.
On Windows `std::chrono::system_clock` is represented as 100s of nanoseconds, ie. `FILETIME`.

Reviewed By: simpkins

Differential Revision: D5308182

fbshipit-source-id: facb922ebe1587723358b38499dadac683e3517b

folly/experimental/logging/test/GlogFormatterTest.cpp

index 067fcb10d74d56ec5c9fd562dc2017f96c5b9956..a10c380ac21cbf08f95b53e3c36286d0329dd201 100644 (file)
@@ -21,6 +21,7 @@
 #include <folly/experimental/logging/LoggerDB.h>
 #include <folly/init/Init.h>
 #include <folly/portability/GTest.h>
+#include <folly/portability/Stdlib.h>
 
 using namespace folly;
 
@@ -47,7 +48,8 @@ std::string formatMsg(
   GlogStyleFormatter formatter;
 
   std::chrono::system_clock::time_point logTimePoint{
-      std::chrono::nanoseconds{timestampNS}};
+      std::chrono::duration_cast<std::chrono::system_clock::duration>(
+          std::chrono::nanoseconds{timestampNS})};
   LogMessage logMessage{
       category, level, logTimePoint, filename, lineNumber, msg.str()};