2017-11-06 18:39:04 +08:00
|
|
|
//
|
|
|
|
// Copyright(c) 2015 Gabi Melman.
|
|
|
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
2019-04-05 21:57:49 +08:00
|
|
|
#include "spdlog/common.h"
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2018-03-17 18:47:46 +08:00
|
|
|
namespace spdlog {
|
|
|
|
namespace details {
|
|
|
|
namespace os {
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2019-04-05 21:44:17 +08:00
|
|
|
spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT;
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2019-04-05 21:44:17 +08:00
|
|
|
std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT;
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2019-04-05 21:44:17 +08:00
|
|
|
std::tm localtime() SPDLOG_NOEXCEPT;
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2019-04-05 21:44:17 +08:00
|
|
|
std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT;
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2019-04-05 21:44:17 +08:00
|
|
|
std::tm gmtime() SPDLOG_NOEXCEPT;
|
2017-11-06 18:39:04 +08:00
|
|
|
|
|
|
|
// eol definition
|
2018-03-09 21:26:33 +08:00
|
|
|
#if !defined(SPDLOG_EOL)
|
2017-11-06 18:39:04 +08:00
|
|
|
#ifdef _WIN32
|
|
|
|
#define SPDLOG_EOL "\r\n"
|
|
|
|
#else
|
|
|
|
#define SPDLOG_EOL "\n"
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2018-03-09 21:26:33 +08:00
|
|
|
SPDLOG_CONSTEXPR static const char *default_eol = SPDLOG_EOL;
|
2017-12-01 09:40:49 +08:00
|
|
|
|
|
|
|
// folder separator
|
|
|
|
#ifdef _WIN32
|
2019-04-05 21:44:17 +08:00
|
|
|
const char folder_sep = '\\';
|
2017-12-01 09:40:49 +08:00
|
|
|
#else
|
|
|
|
SPDLOG_CONSTEXPR static const char folder_sep = '/';
|
|
|
|
#endif
|
|
|
|
|
2019-04-05 21:44:17 +08:00
|
|
|
void prevent_child_fd(FILE *f);
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2018-03-09 21:26:33 +08:00
|
|
|
// fopen_s on non windows for writing
|
2019-04-05 21:44:17 +08:00
|
|
|
bool fopen_s(FILE **fp, const filename_t &filename, const filename_t &mode);
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2019-04-05 21:44:17 +08:00
|
|
|
int remove(const filename_t &filename) SPDLOG_NOEXCEPT;
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2019-04-05 21:44:17 +08:00
|
|
|
int rename(const filename_t &filename1, const filename_t &filename2) SPDLOG_NOEXCEPT;
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2018-03-09 21:26:33 +08:00
|
|
|
// Return if file exists
|
2019-04-05 21:44:17 +08:00
|
|
|
bool file_exists(const filename_t &filename) SPDLOG_NOEXCEPT;
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2018-03-09 21:26:33 +08:00
|
|
|
// Return file size according to open FILE* object
|
2019-04-05 21:44:17 +08:00
|
|
|
size_t filesize(FILE *f);
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2018-03-09 21:26:33 +08:00
|
|
|
// Return utc offset in minutes or throw spdlog_ex on failure
|
2019-04-05 21:44:17 +08:00
|
|
|
int utc_minutes_offset(const std::tm &tm = details::os::localtime());
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2018-03-09 21:26:33 +08:00
|
|
|
// Return current thread id as size_t
|
2018-07-22 04:48:07 +08:00
|
|
|
// It exists because the std::this_thread::get_id() is much slower(especially
|
|
|
|
// under VS 2013)
|
2019-04-05 21:44:17 +08:00
|
|
|
size_t _thread_id() SPDLOG_NOEXCEPT;
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2018-03-09 21:26:33 +08:00
|
|
|
// Return current thread id as size_t (from thread local storage)
|
2019-04-05 21:44:17 +08:00
|
|
|
size_t thread_id() SPDLOG_NOEXCEPT;
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2018-01-12 20:09:07 +08:00
|
|
|
// This is avoid msvc issue in sleep_for that happens if the clock changes.
|
|
|
|
// See https://github.com/gabime/spdlog/issues/609
|
2019-04-05 21:44:17 +08:00
|
|
|
void sleep_for_millis(int milliseconds) SPDLOG_NOEXCEPT;
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2019-05-08 22:16:56 +08:00
|
|
|
std::string filename_to_str(const filename_t &filename) SPDLOG_NOEXCEPT;
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2019-05-08 22:16:56 +08:00
|
|
|
int pid() SPDLOG_NOEXCEPT;
|
2017-11-06 18:39:04 +08:00
|
|
|
|
2017-11-26 06:40:47 +08:00
|
|
|
// Determine if the terminal supports colors
|
2017-11-06 18:39:04 +08:00
|
|
|
// Source: https://github.com/agauniyal/rang/
|
2019-04-05 21:44:17 +08:00
|
|
|
bool is_color_terminal() SPDLOG_NOEXCEPT;
|
2017-11-06 18:39:04 +08:00
|
|
|
|
|
|
|
// Detrmine if the terminal attached
|
|
|
|
// Source: https://github.com/agauniyal/rang/
|
2019-04-05 21:44:17 +08:00
|
|
|
bool in_terminal(FILE *file) SPDLOG_NOEXCEPT;
|
2019-04-06 04:34:55 +08:00
|
|
|
|
|
|
|
#if defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) && defined(_WIN32)
|
|
|
|
void wbuf_to_utf8buf(const fmt::wmemory_buffer &wbuf, fmt::memory_buffer &target);
|
|
|
|
#endif
|
|
|
|
|
2018-03-17 18:47:46 +08:00
|
|
|
} // namespace os
|
|
|
|
} // namespace details
|
|
|
|
} // namespace spdlog
|
2019-04-05 21:44:17 +08:00
|
|
|
|
2019-04-27 23:44:48 +08:00
|
|
|
#ifndef SPDLOG_STATIC_LIB
|
2019-04-27 07:33:33 +08:00
|
|
|
#include "spdlog/impl/os.cpp"
|
2019-04-05 21:44:17 +08:00
|
|
|
#endif
|