Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 38315c0

Browse files
committed
patch for gcc version < 5 std::put_time unavailable
1 parent 3b00c4c commit 38315c0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

include/rpc/detail/log.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,19 @@ class logger {
8383
std::stringstream ss;
8484
timespec now_t = {};
8585
clock_gettime(CLOCK_REALTIME, &now_t);
86+
#if __GNUC__ >= 5
8687
ss << std::put_time(
8788
std::localtime(reinterpret_cast<time_t *>(&now_t.tv_sec)),
8889
"%F %T")
89-
<< RPCLIB_FMT::format(
90+
#else
91+
char mltime[128];
92+
strftime(mltime, sizeof(mltime), "%c %Z",
93+
std::localtime(reinterpret_cast<time_t *>(&now_t.tv_sec)));
94+
ss << mltime
95+
#endif
96+
<< RPCLIB_FMT::format(
9097
".{:03}", round(static_cast<double>(now_t.tv_nsec) / 1.0e6));
98+
9199
return ss.str();
92100
}
93101
#endif

0 commit comments

Comments
 (0)