00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <cstdio>
00015 #include <ctime>
00016
00017 #include "base/logging.h"
00018
00019 DEFINE_int32(log_level, 0, "Log level (0 is the default).");
00020 DEFINE_bool(log_prefix,
00021 true,
00022 "Prefix all log lines with the date, source file and line number.");
00023
00024 namespace operations_research {
00025 DateLogger::DateLogger() {
00026 #if defined(_MSC_VER)
00027 _tzset();
00028 #endif
00029 }
00030
00031 char* const DateLogger::HumanDate() {
00032 #if defined(_MSC_VER)
00033 _strtime_s(buffer_, sizeof(buffer_));
00034 #else
00035 time_t time_value = time(NULL);
00036 struct tm now;
00037 localtime_r(&time_value, &now);
00038 snprintf(buffer_, sizeof(buffer_), "%02d:%02d:%02d\0",
00039 now.tm_hour, now.tm_min, now.tm_sec);
00040 #endif
00041 return buffer_;
00042 }
00043 }