您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

99 行
2.7KB

  1. // Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
  2. // Distributed under the MIT License (http://opensource.org/licenses/MIT)
  3. #pragma once
  4. #include "spdlog/common.h"
  5. #include <ctime> // std::time_t
  6. namespace spdlog {
  7. namespace details {
  8. namespace os {
  9. spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT;
  10. std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT;
  11. std::tm localtime() SPDLOG_NOEXCEPT;
  12. std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT;
  13. std::tm gmtime() SPDLOG_NOEXCEPT;
  14. // eol definition
  15. #if !defined(SPDLOG_EOL)
  16. #ifdef _WIN32
  17. #define SPDLOG_EOL "\r\n"
  18. #else
  19. #define SPDLOG_EOL "\n"
  20. #endif
  21. #endif
  22. SPDLOG_CONSTEXPR static const char *default_eol = SPDLOG_EOL;
  23. // folder separator
  24. #ifdef _WIN32
  25. const char folder_sep = '\\';
  26. #else
  27. SPDLOG_CONSTEXPR static const char folder_sep = '/';
  28. #endif
  29. void prevent_child_fd(FILE *f);
  30. // fopen_s on non windows for writing
  31. bool fopen_s(FILE **fp, const filename_t &filename, const filename_t &mode);
  32. // Remove filename. return 0 on success
  33. int remove(const filename_t &filename) SPDLOG_NOEXCEPT;
  34. // Remove file if exists. return 0 on success
  35. // Note: Non atomic (might return failure to delete if concurrently deleted by other process/thread)
  36. int remove_if_exists(const filename_t &filename) SPDLOG_NOEXCEPT;
  37. int rename(const filename_t &filename1, const filename_t &filename2) SPDLOG_NOEXCEPT;
  38. // Return if file exists.
  39. bool file_exists(const filename_t &filename) SPDLOG_NOEXCEPT;
  40. // Return file size according to open FILE* object
  41. size_t filesize(FILE *f);
  42. // Return utc offset in minutes or throw spdlog_ex on failure
  43. int utc_minutes_offset(const std::tm &tm = details::os::localtime());
  44. // Return current thread id as size_t
  45. // It exists because the std::this_thread::get_id() is much slower(especially
  46. // under VS 2013)
  47. size_t _thread_id() SPDLOG_NOEXCEPT;
  48. // Return current thread id as size_t (from thread local storage)
  49. size_t thread_id() SPDLOG_NOEXCEPT;
  50. // This is avoid msvc issue in sleep_for that happens if the clock changes.
  51. // See https://github.com/gabime/spdlog/issues/609
  52. void sleep_for_millis(int milliseconds) SPDLOG_NOEXCEPT;
  53. std::string filename_to_str(const filename_t &filename);
  54. int pid() SPDLOG_NOEXCEPT;
  55. // Determine if the terminal supports colors
  56. // Source: https://github.com/agauniyal/rang/
  57. bool is_color_terminal() SPDLOG_NOEXCEPT;
  58. // Detrmine if the terminal attached
  59. // Source: https://github.com/agauniyal/rang/
  60. bool in_terminal(FILE *file) SPDLOG_NOEXCEPT;
  61. #if (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) && defined(_WIN32)
  62. void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target);
  63. #endif
  64. } // namespace os
  65. } // namespace details
  66. } // namespace spdlog
  67. #ifdef SPDLOG_HEADER_ONLY
  68. #include "os-inl.h"
  69. #endif