诸暨麻将添加redis
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

60 lines
1.6 KiB

  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 <tuple>
  6. namespace spdlog {
  7. namespace details {
  8. // Helper class for file sinks.
  9. // When failing to open a file, retry several times(5) with a delay interval(10 ms).
  10. // Throw spdlog_ex exception on errors.
  11. class file_helper
  12. {
  13. public:
  14. explicit file_helper() = default;
  15. file_helper(const file_helper &) = delete;
  16. file_helper &operator=(const file_helper &) = delete;
  17. ~file_helper();
  18. void open(const filename_t &fname, bool truncate = false);
  19. void reopen(bool truncate);
  20. void flush();
  21. void close();
  22. void write(const memory_buf_t &buf);
  23. size_t size() const;
  24. const filename_t &filename() const;
  25. //
  26. // return file path and its extension:
  27. //
  28. // "mylog.txt" => ("mylog", ".txt")
  29. // "mylog" => ("mylog", "")
  30. // "mylog." => ("mylog.", "")
  31. // "/dir1/dir2/mylog.txt" => ("/dir1/dir2/mylog", ".txt")
  32. //
  33. // the starting dot in filenames is ignored (hidden files):
  34. //
  35. // ".mylog" => (".mylog". "")
  36. // "my_folder/.mylog" => ("my_folder/.mylog", "")
  37. // "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt")
  38. static std::tuple<filename_t, filename_t> split_by_extension(const filename_t &fname);
  39. private:
  40. const int open_tries_ = 5;
  41. const int open_interval_ = 10;
  42. std::FILE *fd_{nullptr};
  43. filename_t filename_;
  44. };
  45. } // namespace details
  46. } // namespace spdlog
  47. #ifdef SPDLOG_HEADER_ONLY
  48. #include "file_helper-inl.h"
  49. #endif