|
|
@ -74,7 +74,6 @@ namespace details {
|
|
|
|
namespace os {
|
|
|
|
namespace os {
|
|
|
|
|
|
|
|
|
|
|
|
SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT {
|
|
|
|
SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT {
|
|
|
|
|
|
|
|
|
|
|
|
#if defined __linux__ && defined SPDLOG_CLOCK_COARSE
|
|
|
|
#if defined __linux__ && defined SPDLOG_CLOCK_COARSE
|
|
|
|
timespec ts;
|
|
|
|
timespec ts;
|
|
|
|
::clock_gettime(CLOCK_REALTIME_COARSE, &ts);
|
|
|
|
::clock_gettime(CLOCK_REALTIME_COARSE, &ts);
|
|
|
@ -87,7 +86,6 @@ SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SPDLOG_INLINE std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT {
|
|
|
|
SPDLOG_INLINE std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT {
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#ifdef _WIN32
|
|
|
|
std::tm tm;
|
|
|
|
std::tm tm;
|
|
|
|
::localtime_s(&tm, &time_tt);
|
|
|
|
::localtime_s(&tm, &time_tt);
|
|
|
@ -104,7 +102,6 @@ SPDLOG_INLINE std::tm localtime() SPDLOG_NOEXCEPT {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SPDLOG_INLINE std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT {
|
|
|
|
SPDLOG_INLINE std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT {
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#ifdef _WIN32
|
|
|
|
std::tm tm;
|
|
|
|
std::tm tm;
|
|
|
|
::gmtime_s(&tm, &time_tt);
|
|
|
|
::gmtime_s(&tm, &time_tt);
|
|
|
@ -249,7 +246,6 @@ SPDLOG_INLINE size_t filesize(FILE *f) {
|
|
|
|
|
|
|
|
|
|
|
|
// Return utc offset in minutes or throw spdlog_ex on failure
|
|
|
|
// Return utc offset in minutes or throw spdlog_ex on failure
|
|
|
|
SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) {
|
|
|
|
SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) {
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#ifdef _WIN32
|
|
|
|
#if _WIN32_WINNT < _WIN32_WINNT_WS08
|
|
|
|
#if _WIN32_WINNT < _WIN32_WINNT_WS08
|
|
|
|
TIME_ZONE_INFORMATION tzinfo;
|
|
|
|
TIME_ZONE_INFORMATION tzinfo;
|
|
|
@ -258,8 +254,7 @@ SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) {
|
|
|
|
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
|
|
|
|
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
|
|
|
|
auto rv = ::GetDynamicTimeZoneInformation(&tzinfo);
|
|
|
|
auto rv = ::GetDynamicTimeZoneInformation(&tzinfo);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
if (rv == TIME_ZONE_ID_INVALID)
|
|
|
|
if (rv == TIME_ZONE_ID_INVALID) throw_spdlog_ex("Failed getting timezone info. ", errno);
|
|
|
|
throw_spdlog_ex("Failed getting timezone info. ", errno);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int offset = -tzinfo.Bias;
|
|
|
|
int offset = -tzinfo.Bias;
|
|
|
|
if (tm.tm_isdst) {
|
|
|
|
if (tm.tm_isdst) {
|
|
|
@ -388,7 +383,6 @@ SPDLOG_INLINE std::string filename_to_str(const filename_t &filename) { return f
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
SPDLOG_INLINE int pid() SPDLOG_NOEXCEPT {
|
|
|
|
SPDLOG_INLINE int pid() SPDLOG_NOEXCEPT {
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#ifdef _WIN32
|
|
|
|
return conditional_static_cast<int>(::GetCurrentProcessId());
|
|
|
|
return conditional_static_cast<int>(::GetCurrentProcessId());
|
|
|
|
#else
|
|
|
|
#else
|
|
|
@ -430,7 +424,6 @@ SPDLOG_INLINE bool is_color_terminal() SPDLOG_NOEXCEPT {
|
|
|
|
// Determine if the terminal attached
|
|
|
|
// Determine if the terminal attached
|
|
|
|
// Source: https://github.com/agauniyal/rang/
|
|
|
|
// Source: https://github.com/agauniyal/rang/
|
|
|
|
SPDLOG_INLINE bool in_terminal(FILE *file) SPDLOG_NOEXCEPT {
|
|
|
|
SPDLOG_INLINE bool in_terminal(FILE *file) SPDLOG_NOEXCEPT {
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#ifdef _WIN32
|
|
|
|
return ::_isatty(_fileno(file)) != 0;
|
|
|
|
return ::_isatty(_fileno(file)) != 0;
|
|
|
|
#else
|
|
|
|
#else
|
|
|
@ -556,7 +549,6 @@ SPDLOG_INLINE filename_t dir_name(const filename_t &path) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string SPDLOG_INLINE getenv(const char *field) {
|
|
|
|
std::string SPDLOG_INLINE getenv(const char *field) {
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#if defined(__cplusplus_winrt)
|
|
|
|
#if defined(__cplusplus_winrt)
|
|
|
|
return std::string{}; // not supported under uwp
|
|
|
|
return std::string{}; // not supported under uwp
|
|
|
|