Merge pull request #2169 from seker/v1.x_file_event_handlers

file_event_handlers add before_open function
This commit is contained in:
Gabi Melman
2021-11-15 13:36:03 +02:00
committed by GitHub
8 changed files with 29 additions and 17 deletions

View File

@@ -37,6 +37,10 @@ SPDLOG_INLINE void file_helper::open(const filename_t &fname, bool truncate)
auto *mode = SPDLOG_FILENAME_T("ab");
auto *trunc_mode = SPDLOG_FILENAME_T("wb");
if (event_handlers_.before_open)
{
event_handlers_.before_open(filename_);
}
for (int tries = 0; tries < open_tries_; ++tries)
{
// create containing folder if not exists already.

View File

@@ -51,7 +51,7 @@ private:
const unsigned int open_interval_ = 10;
std::FILE *fd_{nullptr};
filename_t filename_;
file_event_handlers_t event_handlers_{nullptr, nullptr, nullptr};
file_event_handlers_t event_handlers_;
};
} // namespace details
} // namespace spdlog