diff options
author | Mihai Moldovan <ionic@ionic.de> | 2017-06-30 23:32:45 +0200 |
---|---|---|
committer | Mihai Moldovan <ionic@ionic.de> | 2017-10-27 08:46:39 +0200 |
commit | fc4a18d3398ec360b28802dff990e2c1c8d368b5 (patch) | |
tree | 60c0c13e50e372524f328925d6b76251e4c0066e | |
parent | 67b0a17faa5240ee924cd90f496a412339d00356 (diff) | |
download | nx-libs-fc4a18d3398ec360b28802dff990e2c1c8d368b5.tar.gz nx-libs-fc4a18d3398ec360b28802dff990e2c1c8d368b5.tar.bz2 nx-libs-fc4a18d3398ec360b28802dff990e2c1c8d368b5.zip |
nxcomp/{configure.ac,Log.cpp}: implement configure-time std::put_time check and use macro value in Log.cpp.
-rw-r--r-- | nxcomp/configure.ac | 17 | ||||
-rw-r--r-- | nxcomp/src/Log.cpp | 3 |
2 files changed, 19 insertions, 1 deletions
diff --git a/nxcomp/configure.ac b/nxcomp/configure.ac index 454ee6a80..a61db32c1 100644 --- a/nxcomp/configure.ac +++ b/nxcomp/configure.ac @@ -74,6 +74,23 @@ AC_ARG_ENABLE([cxx11], [AS_IF([test x$enableval = xyes], [AX_CXX_COMPILE_STDCXX_11([], [mandatory])])]) +# Check if std::put_time is available. +AC_MSG_CHECKING([if std::put_time is available]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM( +[[ +#include <iomanip> +#include <ctime> +]], +[[ +std::time_t t = std::time(NULL); +std::tm tm = *std::localtime(&t); +(void) std::put_time(&tm, "%c"); +]])], + [AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_STD_PUT_TIME, [1], + [Use std::put_time to format times, must be made available by the compiler if turned on.])], + [AC_MSG_RESULT([no])]) + AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], [enable to get info session log output (disabled by default)])], diff --git a/nxcomp/src/Log.cpp b/nxcomp/src/Log.cpp index 3ff47aea8..66ae1bd78 100644 --- a/nxcomp/src/Log.cpp +++ b/nxcomp/src/Log.cpp @@ -31,6 +31,7 @@ #include <iomanip> #include "Log.h" +#include "config.h" NXLog nx_log; @@ -78,7 +79,7 @@ std::string NXLog::stamp_to_string(const NXLogStamp& stamp) const } else { - #if __cplusplus >= 201103L && (!defined(__GNUC__) || __GNUC__ >= 5) + #if HAVE_STD_PUT_TIME oss << " " << std::put_time(&timeinfo, "%Y/%m/%d %H:%M:%S"); #else oss << timestamp.tv_sec; |