File indexing completed on 2025-03-13 09:27:47
0001
0002
0003
0004 #pragma once
0005
0006 #include <spdlog/common.h>
0007 #include <tuple>
0008
0009 namespace spdlog {
0010 namespace details {
0011
0012
0013
0014
0015
0016 class SPDLOG_API file_helper
0017 {
0018 public:
0019 file_helper() = default;
0020 explicit file_helper(const file_event_handlers &event_handlers);
0021
0022 file_helper(const file_helper &) = delete;
0023 file_helper &operator=(const file_helper &) = delete;
0024 ~file_helper();
0025
0026 void open(const filename_t &fname, bool truncate = false);
0027 void reopen(bool truncate);
0028 void flush();
0029 void close();
0030 void write(const memory_buf_t &buf);
0031 size_t size() const;
0032 const filename_t &filename() const;
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 static std::tuple<filename_t, filename_t> split_by_extension(const filename_t &fname);
0048
0049 private:
0050 const int open_tries_ = 5;
0051 const unsigned int open_interval_ = 10;
0052 std::FILE *fd_{nullptr};
0053 filename_t filename_;
0054 file_event_handlers event_handlers_;
0055 };
0056 }
0057 }
0058
0059 #ifdef SPDLOG_HEADER_ONLY
0060 # include "file_helper-inl.h"
0061 #endif